From 6b56c68065b3227327cf0dd9e54c9a5883077d2f Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 17 Aug 2023 12:47:42 -0600 Subject: [PATCH 1/3] Fix regression in autodoc.Documenter.parse_name If the assert statement added in #11523 fails, the build fails and the user only sees `assert matched is not None`; with this change, they will get a proper warning message containing the name of the offending module, and the build will succeed. Signed-off-by: Zack Cerza --- sphinx/ext/autodoc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index d523a2bdb19..14f100e160e 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -387,7 +387,7 @@ def parse_name(self) -> bool: matched = py_ext_sig_re.match(self.name) assert matched is not None explicit_modname, path, base, tp_list, args, retann = matched.groups() - except AttributeError: + except (AttributeError, AssertionError): logger.warning(__('invalid signature for auto%s (%r)') % (self.objtype, self.name), type='autodoc') return False From 5ea92393253a12328f78a9088ca814ecdcd48dec Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Aug 2023 23:21:55 +0100 Subject: [PATCH 2/3] Refactor --- sphinx/ext/autodoc/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 14f100e160e..c042aa71a7f 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -383,14 +383,12 @@ def parse_name(self) -> bool: # first, parse the definition -- auto directives for classes and # functions can contain a signature which is then used instead of # an autogenerated one - try: - matched = py_ext_sig_re.match(self.name) - assert matched is not None - explicit_modname, path, base, tp_list, args, retann = matched.groups() - except (AttributeError, AssertionError): + matched = py_ext_sig_re.match(self.name) + if matched is None: logger.warning(__('invalid signature for auto%s (%r)') % (self.objtype, self.name), type='autodoc') return False + explicit_modname, path, base, tp_list, args, retann = matched.groups() # support explicit module and class name separation via :: if explicit_modname is not None: From 0ebabaf8880fb697f008cf7916f0840708024999 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 20 Aug 2023 23:25:14 +0100 Subject: [PATCH 3/3] CHANGES --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index 95df7062794..3e3a1c58882 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Release 7.2.3 (in development) Bugs fixed ---------- +* Fix regression in ``autodoc.Documenter.parse_name()``. Release 7.2.2 (released Aug 17, 2023) =====================================