Skip to content

Commit 196bcf4

Browse files
authored
feat: Prefer stub over target object if not the same kind
Discussion-mkdocstrings-803: mkdocstrings/mkdocstrings#803 PR-422: #422
1 parent 7237873 commit 196bcf4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/griffe/_internal/merger.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ def _merge_stubs_members(obj: Module | Class, stubs: Module | Class) -> None:
8686
# not the canonical one. Therefore, we must allow merging stubs into the target of an alias,
8787
# as long as the stub and target are of the same kind.
8888
if obj_member.kind is not stub_member.kind:
89+
# If the stub and the target are not of the same kind, prefer the
90+
# stub over the target.
8991
logger.debug(
90-
"Cannot merge stubs for %s: kind %s != %s",
92+
"Source object `%s` will be overwritten by stub object.",
9193
obj_member.path,
92-
stub_member.kind.value,
93-
obj_member.kind.value,
9494
)
95+
obj.set_member(stub_member.name, stub_member)
9596
elif obj_member.is_module:
9697
_merge_module_stubs(obj_member, stub_member) # type: ignore[arg-type]
9798
elif obj_member.is_class:

0 commit comments

Comments
 (0)