Skip to main content

Trying to make mypy understand .objects on abstract django models

Project description

This is an extension on the django-stubs project that attempts to make it possible to work with abstract Django ORM models as if they represent all the concrete models that extend from them.

There are also some extra changes to improve the experience of using this mypy plugin.

The intention is to get this code working and tested and documented before getting those changes into the django-stubs project itself.

Built Docs

https://extended-mypy-django-plugin.readthedocs.io

History

This project comes from working on a large Django project (millions of lines of code) that has varying levels of typing maturity within it. There is work to get this project onto the latest version of mypy and django-stubs, but it is difficult due to 100s of errors introduced by a change from mypy 1.5.0.

Most of these errors are due to using variables that are typed as Abstract Django ORM models when they should be typed as the concrete models that inherit those abstract models. Unfortunately this is not straight forward due to a few factors that mean what concrete models are available can’t be explicitly specified.

This project exists so that it can work with either the old version of django-stubs that is in use or the latest django-stubs. Support for the old version is purely a transitional crutch.

Status

The code works and has reasonable test coverage, but could do with some more and needs some more work done on the documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

extended_mypy_django_plugin-0.7.2.tar.gz (86.9 kB view details)

Uploaded Source

Built Distribution

extended_mypy_django_plugin-0.7.2-py2.py3-none-any.whl (52.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file extended_mypy_django_plugin-0.7.2.tar.gz.

File metadata

File hashes

Hashes for extended_mypy_django_plugin-0.7.2.tar.gz
Algorithm Hash digest
SHA256 3f78300d4169ae475ce11c300d81d3023de8e72dd75607376aba15cf182b467a
MD5 09db3f3755260aff6f575d97d3c5e670
BLAKE2b-256 707b78473dfe8823103720e42d1ffc42367bd022a86a67704b36c44273c68bb5

See more details on using hashes here.

File details

Details for the file extended_mypy_django_plugin-0.7.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for extended_mypy_django_plugin-0.7.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ef6bebcc3f401ba2fad3fe15f9206079d89a691f33a22ac1f46abf4f04843b81
MD5 2c7799c8f0aee3aa02219bd7441114fc
BLAKE2b-256 780cb21ab990ce1966dcb5b1cb4672c8d3e55c2254cd818924813d4070b85d4d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page