mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-10-09 14:55:56 +08:00
Handle GenericForeignKey class typeinfo lookup failure. (#597)
This addresses an obscure crash we're getting when defining a GenericForeignKey subclass on a model. Not sure how this slipped through type checking since `helpers.lookup_class_typeinfo -> Optional[TypeInfo]` while `.get_private_descriptor_type(type_info: TypeInfo)` so this should be a clear type violation.
This commit is contained in:
1 parent
3931432b34
commit
d4c1ed2ce0
2 files changed
+30
-2
No files matched your search
@@ -198,7 +198,12 @@ class DjangoContext:
|
||||
# it's generic, so cannot set specific model
|
||||
field_name = field.name
|
||||
gfk_info = helpers.lookup_class_typeinfo(api, field.__class__)
|
||||
gfk_set_type = helpers.get_private_descriptor_type(gfk_info, "_pyi_private_set_type", is_nullable=True)
|
||||
if gfk_info is None:
|
||||
gfk_set_type = AnyType(TypeOfAny.unannotated)
|
||||
else:
|
||||
gfk_set_type = helpers.get_private_descriptor_type(
|
||||
gfk_info, "_pyi_private_set_type", is_nullable=True
|
||||
)
|
||||
expected_types[field_name] = gfk_set_type
|
||||
|
||||
return expected_types
|
||||
|
||||
Reference in new issue
Block a user