diff --git a/src/griffe/diff.py b/src/griffe/diff.py index bcea8bac..293883b6 100644 --- a/src/griffe/diff.py +++ b/src/griffe/diff.py @@ -446,14 +446,14 @@ def _member_incompatibilities( seen_paths: set[str] | None = None, ) -> Iterator[Breakage]: seen_paths = set() if seen_paths is None else seen_paths - for name, old_member in old_obj.members.items(): + for name, old_member in old_obj.all_members.items(): if ignore_private and name.startswith("_"): logger.debug(f"API check: {old_obj.path}.{name}: skip private object") continue logger.debug(f"API check: {old_obj.path}.{name}") try: - new_member = new_obj.members[name] + new_member = new_obj.all_members[name] except KeyError: is_module = not old_member.is_alias and old_member.is_module if is_module or old_member.is_exported(explicitely=False): diff --git a/tests/test_diff.py b/tests/test_diff.py index eaeebecd..4d1f675f 100644 --- a/tests/test_diff.py +++ b/tests/test_diff.py @@ -185,3 +185,25 @@ def test_diff_griffe(old_code: str, new_code: str, expected_breakages: list[Brea assert len(breaking) == len(expected_breakages) for breakage, expected_kind in zip(breaking, expected_breakages): assert breakage.kind is expected_kind + + +def test_moving_members_in_parent_classes() -> None: + """Test that moving an object from a base class to a parent class doesn't trigger a breakage.""" + old_code = """ + class Parent: + ... + + class Base(Parent): + def method(self): + ... + """ + new_code = """ + class Parent: + def method(self): + ... + + class Base(Parent): + ... + """ + with temporary_visited_module(old_code) as old_package, temporary_visited_module(new_code) as new_package: + assert not list(find_breaking_changes(old_package, new_package))