Skip to content

Commit

Permalink
fix: Fix crash when trying to get a decorator callable path (found th…
Browse files Browse the repository at this point in the history
…anks to pysource-codegen)
  • Loading branch information
pawamoy committed Oct 6, 2023
1 parent fb0a0c1 commit e57f08e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/griffe/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
class ExprSubscript(Expr):
"""Subscripts like `a[b]`."""

left: Expr
left: str | Expr
"""Left part."""
slice: Expr # noqa: A003
"""Slice part."""
Expand All @@ -642,11 +642,15 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
@property
def path(self) -> str:
"""The path of this subscript's left part."""
if isinstance(self.left, str):
return self.left
return self.left.path

@property
def canonical_path(self) -> str:
"""The canonical path of this subscript's left part."""
if isinstance(self.left, str):
return self.left
return self.left.canonical_path


Expand Down

0 comments on commit e57f08e

Please # to comment.