Files
django-stubs/mypy_django_plugin/plugins/postgres_fields.py
2018-11-14 02:33:50 +03:00

15 lines
519 B
Python

from mypy.plugin import FunctionContext
from mypy.types import Type
from mypy_django_plugin import helpers
def determine_type_of_array_field(ctx: FunctionContext) -> Type:
signature = helpers.get_call_signature_or_none(ctx)
if signature is None:
return ctx.default_return_type
_, base_field_arg_type = signature['base_field']
return ctx.api.named_generic_type(ctx.context.callee.fullname,
args=[base_field_arg_type.type.names['__get__'].type.ret_type])