Skip to content

Commit 3cf7958

Browse files
committed
fix: Allow merging stubs into alias targets
1 parent 7d75c71 commit 3cf7958

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/griffe/merger.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ def _merge_stubs_members(obj: Module | Class, stubs: Module | Class) -> None:
6363
continue
6464
obj_member = obj.get_member(member_name)
6565
with suppress(AliasResolutionError, CyclicAliasError):
66-
if obj_member.kind is not stub_member.kind:
66+
# An object's canonical location can differ from its equivalent stub location.
67+
# Devs usually declare stubs at the public location of the corresponding object,
68+
# not the canonical one. Therefore, we must allow merging stubs into the target of an alias,
69+
# as long as the stub and target are of the same kind.
70+
if obj_member.kind is not stub_member.kind and not obj_member.is_alias:
6771
logger.debug(
6872
f"Cannot merge stubs for {obj_member.path}: kind {stub_member.kind.value} != {obj_member.kind.value}",
6973
)

0 commit comments

Comments
 (0)