django-stubs icon indicating copy to clipboard operation
django-stubs copied to clipboard

Too broad return value for apps.get_model()

Open yhoiseth opened this issue 4 years ago • 5 comments

When writing data migrations, you use apps.get_model() instead of the usual model imports.

However, PyCharm doesn't understand that the returned values are models:

Screenshot 2020-01-23 at 16 46 57

The problem is that get_model is set to return Type[Any]. I'll create a pull request to show what I mean.

yhoiseth avatar Jan 23 '20 15:01 yhoiseth

Thanks for the bug report and a quick fix!

sobolevn avatar Jan 23 '20 15:01 sobolevn

No worries! Thanks for your work on django-stubs—I find that it's making Django programming a lot easier and safer 😀

yhoiseth avatar Jan 23 '20 15:01 yhoiseth

@sobolevn Can you please add the help wanted label to this issue?

yhoiseth avatar Feb 09 '20 14:02 yhoiseth

Sure! Thanks a lot for the report.

sobolevn avatar Feb 09 '20 15:02 sobolevn

@sobolevn @RJPercival any chance to get this closed in the near future ?

AdrienLemaire avatar Jul 06 '22 11:07 AdrienLemaire

What about this: https://github.com/typeddjango/django-stubs/pull/1318

I think this fixes it for everyone.

false-vacuum avatar Jan 10 '23 20:01 false-vacuum