Skip to content

Commit 9b5ca45

Browse files
committed
feat: Add resolved property on expression names, returning the corresponding Griffe object
1 parent 20ff7b6 commit 9b5ca45

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/griffe/expressions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,14 @@ def canonical_path(self) -> str:
607607
except NameResolutionError:
608608
return self.name
609609

610+
@property
611+
def resolved(self) -> Module | Class | None:
612+
"""The resolved object this name refers to."""
613+
try:
614+
return self.parent.modules_collection[self.parent.resolve(self.name)] # type: ignore[union-attr]
615+
except Exception: # noqa: BLE001
616+
return self.parent.resolved[self.name] # type: ignore[union-attr,index]
617+
610618
@property
611619
def is_enum_class(self) -> bool:
612620
"""Whether this name resolves to an enumeration class."""

0 commit comments

Comments
 (0)