From 6148f85c56848c6bb3e7df8986f1bb208e7083cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 20 Feb 2023 23:27:32 +0100 Subject: [PATCH] refactor: Rename `relative_filepath` to `relative_package_filepath` to better express what it does --- src/griffe/dataclasses.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/griffe/dataclasses.py b/src/griffe/dataclasses.py index db1120c6..420906d2 100644 --- a/src/griffe/dataclasses.py +++ b/src/griffe/dataclasses.py @@ -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: @@ -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: