14
14
15
15
from mypy_django_plugin .django .context import DjangoContext , LookupsAreUnsupported
16
16
from mypy_django_plugin .lib import fullnames , helpers
17
- from mypy_django_plugin .lib .fullnames import ANY_ATTR_ALLOWED_CLASS_FULLNAME
18
17
from mypy_django_plugin .lib .helpers import parse_bool
19
18
from mypy_django_plugin .transformers .models import get_annotated_type
20
19
@@ -33,7 +32,7 @@ def _extract_model_type_from_queryset(queryset_type: Instance, api: TypeChecker)
33
32
if (
34
33
len (base_type .args )
35
34
and isinstance (base_type .args [0 ], Instance )
36
- and base_type .args [0 ].type . has_base ( fullnames . MODEL_CLASS_FULLNAME )
35
+ and helpers . is_model_type ( base_type .args [0 ].type )
37
36
):
38
37
return base_type .args [0 ]
39
38
return None
@@ -46,7 +45,7 @@ def determine_proper_manager_type(ctx: FunctionContext) -> MypyType:
46
45
outer_model_info = helpers .get_typechecker_api (ctx ).scope .active_class ()
47
46
if (
48
47
outer_model_info is None
49
- or not outer_model_info . has_base ( fullnames . MODEL_CLASS_FULLNAME )
48
+ or not helpers . is_model_type ( outer_model_info )
50
49
or outer_model_info .self_type is None
51
50
or not default_return_type .type .is_generic ()
52
51
):
@@ -123,7 +122,7 @@ def get_values_list_row_type(
123
122
typechecker_api ,
124
123
"Row" ,
125
124
column_types ,
126
- extra_bases = [typechecker_api .named_generic_type (ANY_ATTR_ALLOWED_CLASS_FULLNAME , [])],
125
+ extra_bases = [typechecker_api .named_generic_type (fullnames . ANY_ATTR_ALLOWED_CLASS_FULLNAME , [])],
127
126
)
128
127
else :
129
128
return helpers .make_oneoff_named_tuple (typechecker_api , "Row" , column_types )
@@ -300,9 +299,7 @@ def extract_proper_type_queryset_annotate(ctx: MethodContext, django_context: Dj
300
299
row_type = AnyType (TypeOfAny .implementation_artifact )
301
300
else :
302
301
row_type = api .named_generic_type ("builtins.tuple" , [AnyType (TypeOfAny .from_omitted_generics )])
303
- elif isinstance (original_row_type , Instance ) and original_row_type .type .has_base (
304
- fullnames .MODEL_CLASS_FULLNAME
305
- ):
302
+ elif isinstance (original_row_type , Instance ) and helpers .is_model_type (original_row_type .type ):
306
303
row_type = annotated_type
307
304
else :
308
305
row_type = annotated_type
0 commit comments