summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieleades <33452915+danieleades@users.noreply.github.com>2023-05-12 23:51:59 +0100
committerGitHub <noreply@github.com>2023-05-12 23:51:59 +0100
commit31759d6b082d2216622888173838658fafafb863 (patch)
tree8e9e268f291de6013a4734c86ee835917296d9a3
parent1c5158e01095a59550ba74f362cf1f024073922a (diff)
downloadsphinx-git-31759d6b082d2216622888173838658fafafb863.tar.gz
Expand the mypy whitelist for 'sphinx.util' (#11406)
-rw-r--r--pyproject.toml13
-rw-r--r--sphinx/util/__init__.py4
-rw-r--r--sphinx/util/cfamily.py6
-rw-r--r--sphinx/util/console.py2
-rw-r--r--sphinx/util/matching.py2
-rw-r--r--sphinx/util/typing.py2
6 files changed, 20 insertions, 9 deletions
diff --git a/pyproject.toml b/pyproject.toml
index 3b94db137..fab20f409 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -372,7 +372,18 @@ module = [
"sphinx.roles",
"sphinx.search.*",
"sphinx.testing.*",
- "sphinx.util.*",
+ "sphinx.util",
+ "sphinx.util.display",
+ "sphinx.util.docfields",
+ "sphinx.util.docutils",
+ "sphinx.util.fileutil",
+ "sphinx.util.i18n",
+ "sphinx.util.inspect",
+ "sphinx.util.inventory",
+ "sphinx.util.logging",
+ "sphinx.util.nodes",
+ "sphinx.util.parallel",
+ "sphinx.util.template",
]
disallow_any_generics = false
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index 2f166852c..3e23c55a6 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -44,8 +44,8 @@ from sphinx.util.osutil import ( # noqa: F401
logger = logging.getLogger(__name__)
# Generally useful regular expressions.
-ws_re: re.Pattern = re.compile(r'\s+')
-url_re: re.Pattern = re.compile(r'(?P<schema>.+)://.*')
+ws_re: re.Pattern[str] = re.compile(r'\s+')
+url_re: re.Pattern[str] = re.compile(r'(?P<schema>.+)://.*')
# High-level utility functions.
diff --git a/sphinx/util/cfamily.py b/sphinx/util/cfamily.py
index 32984804b..debe23df4 100644
--- a/sphinx/util/cfamily.py
+++ b/sphinx/util/cfamily.py
@@ -244,8 +244,8 @@ class BaseParser:
self.pos = 0
self.end = len(self.definition)
- self.last_match: re.Match = None
- self._previous_state: tuple[int, re.Match] = (0, None)
+ self.last_match: re.Match[str] | None = None
+ self._previous_state: tuple[int, re.Match[str] | None] = (0, None)
self.otherErrors: list[DefinitionError] = []
# in our tests the following is set to False to capture bad parsing
@@ -297,7 +297,7 @@ class BaseParser:
def warn(self, msg: str) -> None:
logger.warning(msg, location=self.location)
- def match(self, regex: re.Pattern) -> bool:
+ def match(self, regex: re.Pattern[str]) -> bool:
match = regex.match(self.definition, self.pos)
if match is not None:
self._previous_state = (self.pos, self.last_match)
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index f5bce864f..0fc94508b 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -14,7 +14,7 @@ except ImportError:
colorama = None
-_ansi_re: re.Pattern = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
+_ansi_re: re.Pattern[str] = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
codes: dict[str, str] = {}
diff --git a/sphinx/util/matching.py b/sphinx/util/matching.py
index 00d988c3a..0a0be72f7 100644
--- a/sphinx/util/matching.py
+++ b/sphinx/util/matching.py
@@ -83,7 +83,7 @@ class Matcher:
DOTFILES = Matcher(['**/.*'])
-_pat_cache: dict[str, re.Pattern] = {}
+_pat_cache: dict[str, re.Pattern[str]] = {}
def patmatch(name: str, pat: str) -> re.Match[str] | None:
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index d4e87ef1d..fd1e33233 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -61,7 +61,7 @@ Inventory = Dict[str, Dict[str, InventoryItem]]
def get_type_hints(
- obj: Any, globalns: dict[str, Any] | None = None, localns: dict | None = None,
+ obj: Any, globalns: dict[str, Any] | None = None, localns: dict[str, Any] | None = None,
) -> dict[str, Any]:
"""Return a dictionary containing type hints for a function, method, module or class
object.