Viicos / django-autotyping

Automatically add type hints for Django powered applications.
https://viicos.github.io/django-autotyping/
MIT License
46 stars 0 forks source link

DecimalField inferred as Any #71

Closed baojd42 closed 3 months ago

baojd42 commented 3 months ago

Hello! Many thanks to your effort on trying to make django-stubs compatible with Pylance.

I tried this package and the intelliSense for Foreignkey works nicely. However, the other fields such as DecimalField, PositiveSmallIntegerField, etc. are still interferred to Any when being called.

I've added django-autotyping to INSTALLED_APPS, and run the command generate_stubs. The stubs for my models are generated under the folder typings. I then add typings to Pylance's settings python.analysis.stubPath.

Is there anything I missed? Thank you.

Viicos commented 3 months ago

Hello, thanks for the feedback. I'm planning on fixing the issue you are describing directly in the stubs. I have a pending PR for this: https://github.com/typeddjango/django-stubs/pull/1900.

Unfortunately, it requires non trivial changes in the mypy plugin, and I would also like to use a better solution (something as described in https://github.com/microsoft/pyright/discussions/6914), but would require mypy to support https://github.com/python/mypy/issues/3737.

Viicos commented 3 months ago

I'll see if I can add a temporary rule in django-autotyping to basically applies the pending changes I have in the stubs.