Skip to content

Commit

Permalink
fix: Report attributes who lost their value as "unset"
Browse files Browse the repository at this point in the history
Issue #218: #218
PR #225: #225
  • Loading branch information
gpuligundla committed Nov 11, 2023
1 parent 6e55f3b commit dfffa4b
Show file tree
Hide file tree
Showing 2 changed files with 9 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 @@ -415,7 +415,10 @@ def _attribute_incompatibilities(old_attribute: Attribute, new_attribute: Attrib
# if old_attribute.annotation is not None and new_attribute.annotation is not None:
# if not is_subhint(new_attribute.annotation, old_attribute.annotation):
if old_attribute.value != new_attribute.value:
yield AttributeChangedValueBreakage(new_attribute, old_attribute.value, new_attribute.value)
if new_attribute.value is None:
yield AttributeChangedValueBreakage(new_attribute, old_attribute.value, "unset")
else:
yield AttributeChangedValueBreakage(new_attribute, old_attribute.value, new_attribute.value)


def _alias_incompatibilities(
Expand Down
5 changes: 5 additions & 0 deletions tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
"def a(x): ...",
[BreakageKind.PARAMETER_REMOVED],
),
(
"class a:\n\tb: int | None = None",
"class a:\n\tb: int",
[BreakageKind.ATTRIBUTE_CHANGED_VALUE],
),
(
"def a() -> int: ...",
"def a() -> str: ...",
Expand Down

0 comments on commit dfffa4b

Please sign in to comment.