Automatically add type hints for Django powered applications.
MIT License
django-autotyping
enhances your developing experience with Django by providing accurate type hints, without the need for
a custom IDE or mypy plugin:
To understand the why and how, you can refer to the context section.
django-autotyping
is built with LibCST.
[!WARNING] This project is still work in progress. It is meant to work with
django-stubs
, but some improvements and changes are probably going to be implemented in the stub definitions, and could potentially require some changes to the generated stubs.
Through pip
:
pip install django-autotyping
To make use of the dynamic stubs feature, you will also need to install django-stubs
:
pip install django-stubs
As any Django application, you will need to add django_autotyping
to your INSTALLED_APPS
(preferably in your development or local settings, if you already have them separated).
The application is configurable through the AUTOTYPING
dict:
AUTOTYPING = {
"STUBS_GENERATION": {
"LOCAL_STUBS_DIR": Path(BASE_DIR, "typings"),
}
}
[!TIP] To get typing and auto-completion support, you can make use of the
AutotypingSettingsDict
helper:from django_autotyping.typing import AutotypingSettingsDict AUTOTYPING: AutotypingSettingsDict = { ... }
django-autotyping
provides several linting rules, identified with the pattern DJA00X
or DJAS00X
. Rules can be disabled
using the IGNORE
setting value.
For a complete list of available configuration values, refer to the usage section of dynamic stubs and explicit type hints.