Skip to content

Commit

Permalink
refactor: Rename relative_filepath to relative_package_filepath t…
Browse files Browse the repository at this point in the history
…o better express what it does
  • Loading branch information
pawamoy committed Feb 20, 2023
1 parent c48928d commit 6148f85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/griffe/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def filepath(self) -> Path | list[Path]:
return self.module.filepath

@cached_property # noqa: WPS231
def relative_filepath(self) -> Path: # noqa: WPS231
def relative_package_filepath(self) -> Path: # noqa: WPS231
"""Return the file path where this object was defined, relative to the top module path.
Raises:
Expand All @@ -560,23 +560,23 @@ def relative_filepath(self) -> Path: # noqa: WPS231
A file path.
"""
package_path = self.package.filepath
if isinstance(self.module.filepath, list):
if isinstance(self.filepath, list):
if isinstance(package_path, list):
for pkg_path in package_path:
for self_path in self.module.filepath:
for self_path in self.filepath:
with suppress(ValueError):
return self_path.relative_to(pkg_path.parent)
else:
for self_path in self.module.filepath: # noqa: WPS440
for self_path in self.filepath: # noqa: WPS440
with suppress(ValueError):
return self_path.relative_to(package_path.parent.parent)
raise ValueError
if isinstance(package_path, list):
for pkg_path in package_path: # noqa: WPS440
with suppress(ValueError):
return self.module.filepath.relative_to(pkg_path.parent)
return self.filepath.relative_to(pkg_path.parent)
raise ValueError
return self.module.filepath.relative_to(package_path.parent.parent)
return self.filepath.relative_to(package_path.parent.parent)

@cached_property
def path(self) -> str:
Expand Down

0 comments on commit 6148f85

Please sign in to comment.