Skip to content

Commit

Permalink
autosummary: Filter invalid import prefixes in autolink (#12626)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 20, 2024
1 parent 6c486a5 commit bbc97e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ Bugs fixed
``sphinx.ext.autodoc``,
especially when using :mod:`dataclasses` as type metadata.
Patch by Adam Turner.
* #12589, #12626: autosummary: Fix warnings with :rst:role:`!autolink`.
Patch by Adam Turner.

Release 7.4.6 (released Jul 18, 2024)
=====================================

Bugs fixed
----------

* #12859, #9743, #12609: autosummary: Do not add the package prefix when
* #12589, #9743, #12609: autosummary: Do not add the package prefix when
generating autosummary directives for modules within a package.
Patch by Adam Turner.
* #12613: Reduce log severity for ambiguity detection during inventory loading.
Expand Down
9 changes: 8 additions & 1 deletion sphinx/ext/autosummary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,14 @@ def run(self) -> tuple[list[Node], list[system_message]]:
try:
# try to import object by name
prefixes = get_import_prefixes_from_env(self.env)
import_by_name(pending_xref['reftarget'], prefixes)
name = pending_xref['reftarget']
prefixes = [
prefix
for prefix in prefixes
if prefix is None
or not (name.startswith(f'{prefix}.') or name == prefix)
]
import_by_name(name, prefixes)
except ImportExceptionGroup:
literal = cast(nodes.literal, pending_xref[0])
objects[0] = nodes.emphasis(self.rawtext, literal.astext(),
Expand Down

0 comments on commit bbc97e0

Please sign in to comment.