Pygments does not need type checking globally ignored anymore

This commit is contained in:
Kovid Goyal
2026-01-14 22:18:11 +05:30
parent 2d32c1175c
commit edd466e5f7
2 changed files with 36 additions and 31 deletions

View File

@@ -106,7 +106,7 @@ jobs:
${{ runner.os }}-golang-static- ${{ runner.os }}-golang-static-
- name: Install build-only deps - name: Install build-only deps
run: python -m pip install -r docs/requirements.txt ruff mypy types-requests types-docutils run: python -m pip install -r docs/requirements.txt ruff mypy types-requests types-docutils types-Pygments
- name: Run ruff - name: Run ruff
run: ruff check . run: ruff check .

View File

@@ -18,8 +18,9 @@ from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple
from docutils import nodes from docutils import nodes
from docutils.parsers.rst.roles import set_classes from docutils.parsers.rst.roles import set_classes
from pygments.lexer import RegexLexer, bygroups # type: ignore from pygments.lexer import RegexLexer
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, String, Whitespace # type: ignore from pygments.lexer import bygroups as untyped_bygroups
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, String, Whitespace
from sphinx import addnodes, version_info from sphinx import addnodes, version_info
from sphinx.util.logging import getLogger from sphinx.util.logging import getLogger
@@ -367,7 +368,11 @@ def replace_string(app: Any, docname: str, source: List[str]) -> None: # {{{
# config file docs {{{ # config file docs {{{
class ConfLexer(RegexLexer): # type: ignore def bygroups(*args: Any) -> Any:
return untyped_bygroups(*args) # type: ignore[no-untyped-call]
class ConfLexer(RegexLexer):
name = 'Conf' name = 'Conf'
aliases = ['conf'] aliases = ['conf']
filenames = ['*.conf'] filenames = ['*.conf']
@@ -401,7 +406,7 @@ class ConfLexer(RegexLexer): # type: ignore
else: else:
break break
def mapargs(self: RegexLexer, match: 're.Match[str]') -> Iterator[Tuple[int, Any, str]]: def mapargs(self: 'ConfLexer', match: 're.Match[str]') -> Iterator[Tuple[int, Any, str]]:
start_pos = match.start() start_pos = match.start()
val = match.group() val = match.group()
parts = val.split(maxsplit=1) parts = val.split(maxsplit=1)
@@ -465,7 +470,7 @@ class ConfLexer(RegexLexer): # type: ignore
} }
class SessionLexer(RegexLexer): # type: ignore class SessionLexer(RegexLexer):
name = 'Session' name = 'Session'
aliases = ['session'] aliases = ['session']
filenames = ['*.session'] filenames = ['*.session']