Skip to main content

Automatically add type hints for Django powered applications.

Project description

Django Autotyping

Python versions PyPI version Ruff

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

django-autotyping-0.5.0.tar.gz (78.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_autotyping-0.5.0-py3-none-any.whl (96.3 kB view details)

Uploaded Python 3

File details

Details for the file django-autotyping-0.5.0.tar.gz.

File metadata

  • Download URL: django-autotyping-0.5.0.tar.gz
  • Upload date:
  • Size: 78.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for django-autotyping-0.5.0.tar.gz
Algorithm Hash digest
SHA256 22cf53dd7dda617c82767602039ed7a3264e1edf3da9e74573c1668f8afa6b88
MD5 e9968ddbc90a3655094e9d79cf477f12
BLAKE2b-256 f457efb0fd06c8490506e48947fe158f6042f0ccd35fa88005b0d2acaa1ae757

See more details on using hashes here.

File details

Details for the file django_autotyping-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_autotyping-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c44b9ebcb2c3d3512faf2aa71d9dfbf3739fc9cb6a6ac35158f566a62406332
MD5 4a5eb1b50cc2f17ba44c08b7050d08c0
BLAKE2b-256 a9f65e71c76655531a79527578617fe993eaa75e315efdf68e365eb86281fcdb

See more details on using hashes here.

Supported by

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