Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>2022-09-27 17:18:20 +0300
committerGitHub <noreply@github.com>2022-09-27 17:18:20 +0300
commit89b4f14b44ff239d7c8ef681ed633090c179f0b0 (patch)
tree49aea5aa3eef5723cb6b622efa0b94e9ecd5ce0b
parente0dbbc510af04970a22dcd1e836032cc29b87da2 (diff)
Fix mypy violations for v0.981 (#10875)
-rw-r--r--pyproject.toml2
-rw-r--r--sphinx/domains/std.py2
-rw-r--r--sphinx/util/parallel.py5
-rw-r--r--sphinx/util/typing.py16
4 files changed, 13 insertions, 12 deletions
diff --git a/pyproject.toml b/pyproject.toml
index 14ca5d092..21cf38b0b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -86,7 +86,7 @@ lint = [
"flake8-bugbear",
"flake8-simplify",
"isort",
- "mypy>=0.971",
+ "mypy>=0.981",
"sphinx-lint",
"docutils-stubs",
"types-typed-ast",
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 68cab115c..c6a05875f 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -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:
diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py
index 267f7bd4c..16a95e039 100644
--- a/sphinx/util/parallel.py
+++ b/sphinx/util/parallel.py
@@ -19,10 +19,11 @@ from sphinx.util import logging
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'
@@ -92,7 +93,7 @@ class ParallelTasks:
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
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index 518ea8771..c57cb7c5c 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -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:
@@ -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)