Skip to content

Commit

Permalink
feat: Add resolved property on expression names, returning the corr…
Browse files Browse the repository at this point in the history
…esponding Griffe object
  • Loading branch information
pawamoy committed Apr 19, 2024
1 parent 20ff7b6 commit 9b5ca45
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/griffe/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,14 @@ def canonical_path(self) -> str:
except NameResolutionError:
return self.name

@property
def resolved(self) -> Module | Class | None:
"""The resolved object this name refers to."""
try:
return self.parent.modules_collection[self.parent.resolve(self.name)] # type: ignore[union-attr]
except Exception: # noqa: BLE001
return self.parent.resolved[self.name] # type: ignore[union-attr,index]

@property
def is_enum_class(self) -> bool:
"""Whether this name resolves to an enumeration class."""
Expand Down

0 comments on commit 9b5ca45

Please sign in to comment.