look for models.Model in full mro for to= parameter

This commit is contained in:
Maxim Kurnikov
2019-01-25 17:23:34 +03:00
parent bc4bc31722
commit 38e841c4c7
2 changed files with 12 additions and 4 deletions

View File

@@ -48,10 +48,7 @@ def get_valid_to_value_or_none(ctx: FunctionContext) -> Optional[Instance]:
referred_to_type = arg_type.ret_type
if not isinstance(referred_to_type, Instance):
return None
for base in referred_to_type.type.bases:
if base.type.fullname() == helpers.MODEL_CLASS_FULLNAME:
break
else:
if not referred_to_type.type.has_base(helpers.MODEL_CLASS_FULLNAME):
ctx.api.msg.fail(f'to= parameter value must be '
f'a subclass of {helpers.MODEL_CLASS_FULLNAME}',
context=ctx.context)