Skip to content

Commit

Permalink
refactor: Only return 0 for the line number of removed objects when t…
Browse files Browse the repository at this point in the history
…he location is reworked as relative
  • Loading branch information
pawamoy committed Feb 10, 2024
1 parent d153fa0 commit 3a4d054
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/griffe/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def _relative_path(self) -> str:

@property
def _lineno(self) -> int:
if self.kind is BreakageKind.OBJECT_REMOVED:
# If the object was removed, and we are able to get the location (file path)
# as a relative path, then we use 0 instead of the original line number
# (it helps when checking current sources, and avoids pointing to now missing contents).
if self.kind is BreakageKind.OBJECT_REMOVED and self._relative_filepath != self._location:
return 0
if self.obj.is_alias:
return self.obj.alias_lineno or 0 # type: ignore[attr-defined]
Expand Down

0 comments on commit 3a4d054

Please sign in to comment.