mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-05-17 22:09:45 +08:00
fix mypy errors
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.core.exceptions import FieldDoesNotExist
|
||||
from mypy.nodes import TypeInfo
|
||||
from mypy.plugin import MethodContext
|
||||
from mypy.types import AnyType, Instance
|
||||
from mypy.types import Type as MypyType
|
||||
@@ -9,11 +10,16 @@ from mypy_django_plugin.lib import fullnames, helpers
|
||||
|
||||
|
||||
def _get_field_instance(ctx: MethodContext, field_fullname: str) -> MypyType:
|
||||
field_info = helpers.lookup_fully_qualified_typeinfo(ctx.api, field_fullname)
|
||||
field_info = helpers.lookup_fully_qualified_typeinfo(helpers.get_typechecker_api(ctx),
|
||||
field_fullname)
|
||||
assert isinstance(field_info, TypeInfo)
|
||||
return Instance(field_info, [AnyType(TypeOfAny.explicit), AnyType(TypeOfAny.explicit)])
|
||||
|
||||
|
||||
def return_proper_field_type_from_get_field(ctx: MethodContext, django_context: DjangoContext) -> MypyType:
|
||||
# Options instance
|
||||
assert isinstance(ctx.type, Instance)
|
||||
|
||||
model_type = ctx.type.args[0]
|
||||
if not isinstance(model_type, Instance):
|
||||
return _get_field_instance(ctx, fullnames.FIELD_FULLNAME)
|
||||
|
||||
Reference in New Issue
Block a user