From 7a6f1a85d2973bdf7f0aa91f318dfe807046496d Mon Sep 17 00:00:00 2001 From: STerliakov Date: Mon, 12 May 2025 23:16:06 +0200 Subject: [PATCH] Fall back to Incomplete if we are unable to determine the module name --- mypy/stubgenc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index b03a88cf6f43..b675079dd8dd 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -769,7 +769,11 @@ def get_type_fullname(self, typ: type) -> str: return "Any" typename = getattr(typ, "__qualname__", typ.__name__) module_name = self.get_obj_module(typ) - assert module_name is not None, typ + if module_name is None: + # This should not normally happen, but some types may resist our + # introspection attempts too hard. See + # https://github.com/python/mypy/issues/19031 + return "_typeshed.Incomplete" if module_name != "builtins": typename = f"{module_name}.{typename}" return typename