Skip to content

Commit

Permalink
fix: Allow merging stubs into alias targets
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 14, 2024
1 parent 7d75c71 commit 3cf7958
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/griffe/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def _merge_stubs_members(obj: Module | Class, stubs: Module | Class) -> None:
continue
obj_member = obj.get_member(member_name)
with suppress(AliasResolutionError, CyclicAliasError):
if obj_member.kind is not stub_member.kind:
# An object's canonical location can differ from its equivalent stub location.
# Devs usually declare stubs at the public location of the corresponding object,
# not the canonical one. Therefore, we must allow merging stubs into the target of an alias,
# as long as the stub and target are of the same kind.
if obj_member.kind is not stub_member.kind and not obj_member.is_alias:
logger.debug(
f"Cannot merge stubs for {obj_member.path}: kind {stub_member.kind.value} != {obj_member.kind.value}",
)
Expand Down

0 comments on commit 3cf7958

Please sign in to comment.