Skip to content

Commit e1f3ed9

Browse files
committed
fix: Don't crash when trying to merge stubs into a compiled module that has no file path
Issue-323: #323
1 parent 676cfb4 commit e1f3ed9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/_griffe/mixins.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import TYPE_CHECKING, Any, Sequence, TypeVar
99

1010
from _griffe.enumerations import Kind
11-
from _griffe.exceptions import AliasResolutionError, CyclicAliasError
11+
from _griffe.exceptions import AliasResolutionError, BuiltinModuleError, CyclicAliasError
1212
from _griffe.merger import merge_stubs
1313

1414
if TYPE_CHECKING:
@@ -204,7 +204,9 @@ def set_member(self, key: str | Sequence[str], value: Object | Alias) -> None:
204204
# try to merge them as one regular and one stubs module
205205
# (implicit support for .pyi modules).
206206
if member.is_module and not (member.is_namespace_package or member.is_namespace_subpackage):
207-
with suppress(AliasResolutionError, CyclicAliasError):
207+
# Accessing attributes of the value or member can trigger alias errors.
208+
# Accessing file paths can trigger a builtin module error.
209+
with suppress(AliasResolutionError, CyclicAliasError, BuiltinModuleError):
208210
if value.is_module and value.filepath != member.filepath:
209211
with suppress(ValueError):
210212
value = merge_stubs(member, value) # type: ignore[arg-type]

0 commit comments

Comments
 (0)