Skip to content

Commit

Permalink
fix: Prevent alias resolution errors when copying docstring or labels…
Browse files Browse the repository at this point in the history
… from previously existing attribute
  • Loading branch information
pawamoy committed Mar 31, 2023
1 parent 736ce99 commit 48747b6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/griffe/agents/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
ParameterKind,
Parameters,
)
from griffe.exceptions import LastNodeError, NameResolutionError
from griffe.exceptions import AliasResolutionError, CyclicAliasError, LastNodeError, NameResolutionError
from griffe.extensions import Extensions

if TYPE_CHECKING:
Expand Down Expand Up @@ -590,11 +590,11 @@ def handle_attribute(
if isinstance(node.parent, (ast.If, ast.ExceptHandler)): # type: ignore[union-attr]
continue # prefer "no-exception" case

parent.members[name].labels |= labels # type: ignore[misc]

# forward previous docstring instead of erasing it
if parent.members[name].docstring and not docstring:
docstring = parent.members[name].docstring
with suppress(AliasResolutionError, CyclicAliasError):
labels |= parent.members[name].labels # type: ignore[misc]
# forward previous docstring instead of erasing it
if parent.members[name].docstring and not docstring:
docstring = parent.members[name].docstring

attribute = Attribute(
name=name,
Expand Down

0 comments on commit 48747b6

Please sign in to comment.