Skip to content

Commit 89b4f14

Browse files
authored
Fix mypy violations for v0.981 (#10875)
1 parent e0dbbc5 commit 89b4f14

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ lint = [
8686
"flake8-bugbear",
8787
"flake8-simplify",
8888
"isort",
89-
"mypy>=0.971",
89+
"mypy>=0.981",
9090
"sphinx-lint",
9191
"docutils-stubs",
9292
"types-typed-ast",

sphinx/domains/std.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GenericObject(ObjectDescription[str]):
4747
A generic x-ref directive registered with Sphinx.add_object_type().
4848
"""
4949
indextemplate: str = ''
50-
parse_node: Callable[["GenericObject", "BuildEnvironment", str, desc_signature], str] = None # NOQA
50+
parse_node: Callable[["BuildEnvironment", str, desc_signature], str] = None # NOQA
5151

5252
def handle_signature(self, sig: str, signode: desc_signature) -> str:
5353
if self.parse_node:

sphinx/util/parallel.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
logger = logging.getLogger(__name__)
2020

2121
if sys.platform != "win32":
22+
ForkContext = multiprocessing.context.ForkContext
2223
ForkProcess = multiprocessing.context.ForkProcess
2324
else:
2425
# For static typing, as ForkProcess doesn't exist on Windows
25-
ForkProcess = multiprocessing.process.BaseProcess
26+
ForkContext = ForkProcess = Any
2627

2728
# our parallel functionality only works for the forking Process
2829
parallel_available = multiprocessing and os.name == 'posix'
@@ -92,7 +93,7 @@ def add_task(
9293
self._result_funcs[tid] = result_func or (lambda arg, result: None)
9394
self._args[tid] = arg
9495
precv, psend = multiprocessing.Pipe(False)
95-
context = multiprocessing.get_context('fork')
96+
context: ForkContext = multiprocessing.get_context('fork')
9697
proc = context.Process(target=self._process, args=(psend, task_func, arg))
9798
self._procs[tid] = proc
9899
self._precvsWaiting[tid] = precv

sphinx/util/typing.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _restify_py36(cls: Optional[Type], mode: str = 'fully-qualified-except-typin
267267
return reftext + '\\ [%s]' % param_str
268268
else:
269269
return reftext
270-
elif isinstance(cls, typing.GenericMeta):
270+
elif isinstance(cls, typing.GenericMeta): # type: ignore[attr-defined]
271271
if module == 'typing':
272272
reftext = ':py:class:`~typing.%s`' % qualname
273273
else:
@@ -505,16 +505,16 @@ def _stringify_py36(annotation: Any, mode: str = 'fully-qualified-except-typing'
505505
return '%s%s[%s]' % (modprefix, qualname, param_str)
506506
else:
507507
return modprefix + qualname
508-
elif isinstance(annotation, typing.GenericMeta):
508+
elif isinstance(annotation, typing.GenericMeta): # type: ignore[attr-defined]
509509
params = None
510-
if annotation.__args__ is None or len(annotation.__args__) <= 2: # type: ignore # NOQA
511-
params = annotation.__args__ # type: ignore
512-
elif annotation.__origin__ == Generator: # type: ignore
513-
params = annotation.__args__ # type: ignore
510+
if annotation.__args__ is None or len(annotation.__args__) <= 2: # NOQA
511+
params = annotation.__args__
512+
elif annotation.__origin__ == Generator:
513+
params = annotation.__args__
514514
else: # typing.Callable
515515
args = ', '.join(stringify(arg, mode) for arg
516-
in annotation.__args__[:-1]) # type: ignore
517-
result = stringify(annotation.__args__[-1]) # type: ignore
516+
in annotation.__args__[:-1])
517+
result = stringify(annotation.__args__[-1])
518518
return '%s%s[[%s], %s]' % (modprefix, qualname, args, result)
519519
if params is not None:
520520
param_str = ', '.join(stringify(p, mode) for p in params)

0 commit comments

Comments
 (0)