Skip to content

Commit 81f6285

Browse files
authored
Fall back to Incomplete if we are unable to determine the module name (#19084)
Fixes crash in #19031, but the support of `cvar` in SWIG remains an open question.
1 parent addcff2 commit 81f6285

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy/stubgenc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,11 @@ def get_type_fullname(self, typ: type) -> str:
769769
return "Any"
770770
typename = getattr(typ, "__qualname__", typ.__name__)
771771
module_name = self.get_obj_module(typ)
772-
assert module_name is not None, typ
772+
if module_name is None:
773+
# This should not normally happen, but some types may resist our
774+
# introspection attempts too hard. See
775+
# https://github.com/python/mypy/issues/19031
776+
return "_typeshed.Incomplete"
773777
if module_name != "builtins":
774778
typename = f"{module_name}.{typename}"
775779
return typename

0 commit comments

Comments
 (0)