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.

[!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.

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": {
        "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.

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.3.0.tar.gz (69.0 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.3.0-py3-none-any.whl (82.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-autotyping-0.3.0.tar.gz
  • Upload date:
  • Size: 69.0 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.3.0.tar.gz
Algorithm Hash digest
SHA256 161767ec46d2cc5e203eed7974d4cec5dac1d34e61d636e7d4e3ac0f4c6e3925
MD5 5aa04e5273c289884a29b8f5b2fd7db7
BLAKE2b-256 7ff952914ac6ef7b69d63f54bc41c73c52a96b601132194aa027fa7d77eb89e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_autotyping-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7839f835f612af15c9061df438b8700796b62e181ade683d93207f379d9c6d89
MD5 53f6525489d0df3e9f261053919f184c
BLAKE2b-256 419de81ccd2899647b3baae91f061f295788ed1b6922266b653b5aaef3fc76a3

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