From 89b4f14b44ff239d7c8ef681ed633090c179f0b0 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:18:20 +0100 Subject: [PATCH 1/5] Fix mypy violations for v0.981 (#10875) --- pyproject.toml | 2 +- sphinx/domains/std.py | 2 +- sphinx/util/parallel.py | 5 +++-- sphinx/util/typing.py | 16 ++++++++-------- 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) From 635540c1808003151623566695f4776472c26e65 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:26:42 +0100 Subject: [PATCH 2/5] Restore anchor links to top of module docstring --- sphinx/domains/javascript.py | 3 ++- sphinx/domains/python.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py index b77c8dff0..b78dfd30e 100644 --- a/sphinx/domains/javascript.py +++ b/sphinx/domains/javascript.py @@ -298,7 +298,7 @@ class JSModule(SphinxDirective): content_node.document = self.state.document nested_parse_with_titles(self.state, self.content, content_node) - ret: List[Node] = [*content_node.children] + ret: List[Node] = [] if not noindex: domain = cast(JavaScriptDomain, self.env.get_domain('js')) @@ -315,6 +315,7 @@ class JSModule(SphinxDirective): indextext = _('%s (module)') % mod_name inode = addnodes.index(entries=[('single', indextext, node_id, '', None)]) ret.append(inode) + ret.extend(content_node.children) return ret def make_old_id(self, modname: str) -> str: diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 6076eb7fb..bd507a21c 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -1024,7 +1024,7 @@ class PyModule(SphinxDirective): content_node.document = self.state.document nested_parse_with_titles(self.state, self.content, content_node) - ret: List[Node] = [*content_node.children] + ret: List[Node] = [] if not noindex: # note module to the domain node_id = make_id(self.env, self.state.document, 'module', modname) @@ -1045,6 +1045,7 @@ class PyModule(SphinxDirective): indextext = '%s; %s' % (pairindextypes['module'], modname) inode = addnodes.index(entries=[('pair', indextext, node_id, '', None)]) ret.append(inode) + ret.extend(content_node.children) return ret def make_old_id(self, name: str) -> str: From 19c278313b9d20052ca6fdb87a4ad498e7fe2c50 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:51:46 +0100 Subject: [PATCH 3/5] Correct error in release date for Sphinx 5.2.1 --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 75a9ab0db..af3d027f3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -Release 5.2.1 (released Sep 24, 2022) +Release 5.2.1 (released Sep 25, 2022) ===================================== Bugs fixed From 335f335a587b162f760f505182ca7922df929b1a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:53:38 +0100 Subject: [PATCH 4/5] Restore anchor links to top of module docstring --- CHANGES | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index af3d027f3..6c0fd0b59 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Release 5.2.2 (in development) +===================================== + +* #10872: Restore link targets for autodoc modules to the top of content. + Patch by Dominic Davis-Foster. + Release 5.2.1 (released Sep 25, 2022) ===================================== From a651e6bf4ad7a1dc293525d0a70e6d0d11b827db Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:54:01 +0100 Subject: [PATCH 5/5] Bump to 5.2.2 final --- CHANGES | 2 +- sphinx/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 6c0fd0b59..6c45cbf61 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -Release 5.2.2 (in development) +Release 5.2.2 (released Sep 27, 2022) ===================================== * #10872: Restore link targets for autodoc modules to the top of content. diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 9cdb8f742..4c4067684 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -19,7 +19,7 @@ warnings.filterwarnings('ignore', "'U' mode is deprecated", warnings.filterwarnings('ignore', 'The frontend.Option class .*', DeprecationWarning, module='docutils.frontend') -__version__ = '5.2.1' +__version__ = '5.2.2' __display_version__ = __version__ # used for command line version #: Version info for better programmatic use. @@ -30,7 +30,7 @@ __display_version__ = __version__ # used for command line version #: #: .. versionadded:: 1.2 #: Before version 1.2, check the string ``sphinx.__version__``. -version_info = (5, 2, 1, 'final', 0) +version_info = (5, 2, 2, 'final', 0) package_dir = path.abspath(path.dirname(__file__))