Skip to content

Commit

Permalink
chore: Add message to exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed May 22, 2023
1 parent d29b59a commit c1b08b1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/griffe/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def module(self) -> Module:
return self
if self.parent is not None:
return self.parent.module
raise ValueError
raise ValueError(f"Object {self.name} does not have a parent module")

@cached_property
def package(self) -> Module:
Expand Down Expand Up @@ -1259,6 +1259,19 @@ def filepath(self) -> Path | list[Path]:
raise BuiltinModuleError(self.name)
return self._filepath

@cached_property
def imports_future_annotations(self) -> bool:
"""Tell whether this module import future annotations.
Returns:
True or false.
"""
return (
"annotations" in self.members
and self.members["annotations"].is_alias
and self.members["annotations"].target_path == "__future__.annotations" # type: ignore[union-attr]
)

@cached_property
def is_init_module(self) -> bool:
"""Tell if this module is an `__init__.py` module.
Expand Down

0 comments on commit c1b08b1

Please sign in to comment.