diff --git a/src/griffe/diff.py b/src/griffe/diff.py index 7521f901..b36617de 100644 --- a/src/griffe/diff.py +++ b/src/griffe/diff.py @@ -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( diff --git a/tests/test_diff.py b/tests/test_diff.py index 4d1f675f..c1663a31 100644 --- a/tests/test_diff.py +++ b/tests/test_diff.py @@ -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: ...",