Skip to content

Commit 31759d6

Browse files
authored
Expand the mypy whitelist for 'sphinx.util' (#11406)
1 parent 1c5158e commit 31759d6

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,18 @@ module = [
372372
"sphinx.roles",
373373
"sphinx.search.*",
374374
"sphinx.testing.*",
375-
"sphinx.util.*",
375+
"sphinx.util",
376+
"sphinx.util.display",
377+
"sphinx.util.docfields",
378+
"sphinx.util.docutils",
379+
"sphinx.util.fileutil",
380+
"sphinx.util.i18n",
381+
"sphinx.util.inspect",
382+
"sphinx.util.inventory",
383+
"sphinx.util.logging",
384+
"sphinx.util.nodes",
385+
"sphinx.util.parallel",
386+
"sphinx.util.template",
376387
]
377388
disallow_any_generics = false
378389

sphinx/util/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
logger = logging.getLogger(__name__)
4545

4646
# Generally useful regular expressions.
47-
ws_re: re.Pattern = re.compile(r'\s+')
48-
url_re: re.Pattern = re.compile(r'(?P<schema>.+)://.*')
47+
ws_re: re.Pattern[str] = re.compile(r'\s+')
48+
url_re: re.Pattern[str] = re.compile(r'(?P<schema>.+)://.*')
4949

5050

5151
# High-level utility functions.

sphinx/util/cfamily.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ def __init__(self, definition: str, *,
244244

245245
self.pos = 0
246246
self.end = len(self.definition)
247-
self.last_match: re.Match = None
248-
self._previous_state: tuple[int, re.Match] = (0, None)
247+
self.last_match: re.Match[str] | None = None
248+
self._previous_state: tuple[int, re.Match[str] | None] = (0, None)
249249
self.otherErrors: list[DefinitionError] = []
250250

251251
# in our tests the following is set to False to capture bad parsing
@@ -297,7 +297,7 @@ def fail(self, msg: str) -> None:
297297
def warn(self, msg: str) -> None:
298298
logger.warning(msg, location=self.location)
299299

300-
def match(self, regex: re.Pattern) -> bool:
300+
def match(self, regex: re.Pattern[str]) -> bool:
301301
match = regex.match(self.definition, self.pos)
302302
if match is not None:
303303
self._previous_state = (self.pos, self.last_match)

sphinx/util/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
colorama = None
1515

1616

17-
_ansi_re: re.Pattern = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
17+
_ansi_re: re.Pattern[str] = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
1818
codes: dict[str, str] = {}
1919

2020

sphinx/util/matching.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def match(self, string: str) -> bool:
8383
DOTFILES = Matcher(['**/.*'])
8484

8585

86-
_pat_cache: dict[str, re.Pattern] = {}
86+
_pat_cache: dict[str, re.Pattern[str]] = {}
8787

8888

8989
def patmatch(name: str, pat: str) -> re.Match[str] | None:

sphinx/util/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def is_invalid_builtin_class(obj: Any) -> bool:
6161

6262

6363
def get_type_hints(
64-
obj: Any, globalns: dict[str, Any] | None = None, localns: dict | None = None,
64+
obj: Any, globalns: dict[str, Any] | None = None, localns: dict[str, Any] | None = None,
6565
) -> dict[str, Any]:
6666
"""Return a dictionary containing type hints for a function, method, module or class
6767
object.

0 commit comments

Comments
 (0)