Skip to content

Commit

Permalink
Fix mypy violations for v0.981 (#10875)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 27, 2022
1 parent e0dbbc5 commit 89b4f14
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -86,7 +86,7 @@ lint = [
"flake8-bugbear",
"flake8-simplify",
"isort",
"mypy>=0.971",
"mypy>=0.981",
"sphinx-lint",
"docutils-stubs",
"types-typed-ast",
Expand Down
2 changes: 1 addition & 1 deletion sphinx/domains/std.py
Expand Up @@ -47,7 +47,7 @@ class GenericObject(ObjectDescription[str]):
A generic x-ref directive registered with Sphinx.add_object_type().
"""
indextemplate: str = ''
parse_node: Callable[["GenericObject", "BuildEnvironment", str, desc_signature], str] = None # NOQA
parse_node: Callable[["BuildEnvironment", str, desc_signature], str] = None # NOQA

def handle_signature(self, sig: str, signode: desc_signature) -> str:
if self.parse_node:
Expand Down
5 changes: 3 additions & 2 deletions sphinx/util/parallel.py
Expand Up @@ -19,10 +19,11 @@
logger = logging.getLogger(__name__)

if sys.platform != "win32":
ForkContext = multiprocessing.context.ForkContext
ForkProcess = multiprocessing.context.ForkProcess
else:
# For static typing, as ForkProcess doesn't exist on Windows
ForkProcess = multiprocessing.process.BaseProcess
ForkContext = ForkProcess = Any

# our parallel functionality only works for the forking Process
parallel_available = multiprocessing and os.name == 'posix'
Expand Down Expand Up @@ -92,7 +93,7 @@ def add_task(
self._result_funcs[tid] = result_func or (lambda arg, result: None)
self._args[tid] = arg
precv, psend = multiprocessing.Pipe(False)
context = multiprocessing.get_context('fork')
context: ForkContext = multiprocessing.get_context('fork')
proc = context.Process(target=self._process, args=(psend, task_func, arg))
self._procs[tid] = proc
self._precvsWaiting[tid] = precv
Expand Down
16 changes: 8 additions & 8 deletions sphinx/util/typing.py
Expand Up @@ -267,7 +267,7 @@ def _restify_py36(cls: Optional[Type], mode: str = 'fully-qualified-except-typin
return reftext + '\\ [%s]' % param_str
else:
return reftext
elif isinstance(cls, typing.GenericMeta):
elif isinstance(cls, typing.GenericMeta): # type: ignore[attr-defined]
if module == 'typing':
reftext = ':py:class:`~typing.%s`' % qualname
else:
Expand Down Expand Up @@ -505,16 +505,16 @@ def _stringify_py36(annotation: Any, mode: str = 'fully-qualified-except-typing'
return '%s%s[%s]' % (modprefix, qualname, param_str)
else:
return modprefix + qualname
elif isinstance(annotation, typing.GenericMeta):
elif isinstance(annotation, typing.GenericMeta): # type: ignore[attr-defined]
params = None
if annotation.__args__ is None or len(annotation.__args__) <= 2: # type: ignore # NOQA
params = annotation.__args__ # type: ignore
elif annotation.__origin__ == Generator: # type: ignore
params = annotation.__args__ # type: ignore
if annotation.__args__ is None or len(annotation.__args__) <= 2: # NOQA
params = annotation.__args__
elif annotation.__origin__ == Generator:
params = annotation.__args__
else: # typing.Callable
args = ', '.join(stringify(arg, mode) for arg
in annotation.__args__[:-1]) # type: ignore
result = stringify(annotation.__args__[-1]) # type: ignore
in annotation.__args__[:-1])
result = stringify(annotation.__args__[-1])
return '%s%s[[%s], %s]' % (modprefix, qualname, args, result)
if params is not None:
param_str = ', '.join(stringify(p, mode) for p in params)
Expand Down

0 comments on commit 89b4f14

Please sign in to comment.