Automatically add type hints for Django powered applications.
Project description
Django Autotyping
django-autotyping
enhances your developing experience with Django by providing accurate type hints, without the need for
a custom IDE or mypy plugin:
- Generates custom type stubs based on the current state of your Django application, enhancing your development experience by providing auto-completions and accurate type checking.
- Automatically add explicit type hints to your source code when type stubs are not enough.
To understand the why and how, you can refer to the context section.
django-autotyping
is built with LibCST.
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.
Installation
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
Configuration
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"),
}
}
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.
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
Built Distribution
File details
Details for the file django_autotyping-0.5.1.tar.gz
.
File metadata
- Download URL: django_autotyping-0.5.1.tar.gz
- Upload date:
- Size: 79.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b48c57d3d358a608109dd47698e64466e596983e8729bff130669dd744588c25 |
|
MD5 | dc2f5d5eed8d474d7c8eb4d7cc36ea9b |
|
BLAKE2b-256 | 7bd465d2b1c54f35116bd2d31d1064c523ded729353633389ecfc283a93b4c47 |
File details
Details for the file django_autotyping-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: django_autotyping-0.5.1-py3-none-any.whl
- Upload date:
- Size: 96.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee6ecd32a8d16e858ebce06d8d7ca5b477b32752a8143de48edc67b97d9084d |
|
MD5 | 72d99f88029653fd2d6dbd63caff53cb |
|
BLAKE2b-256 | c798824638898b8272178610268e126cca4f35e0ac05536153f559c299149ac6 |