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": {
        "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.4.0.tar.gz (76.9 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.4.0-py3-none-any.whl (93.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-autotyping-0.4.0.tar.gz
  • Upload date:
  • Size: 76.9 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.4.0.tar.gz
Algorithm Hash digest
SHA256 707115d2e541cdce4bf0ce8774440ae0f95fb4633509fa422487df8550279b27
MD5 864d16e69c13caa299e8a072bb92a2c0
BLAKE2b-256 674efeaf9ffafea3f501e683723976580ed4d268ba7ba6d4443c4fbeef996fba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_autotyping-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2a6fbfebbd240ab3fbcc2ce6798b580cab7c80f895b2b84905c7dfa64e5d781
MD5 bcdae0b8d3ad2d3f5021f0a94bfa2f5b
BLAKE2b-256 dc80098caff11a72df77ad8339b2c41a5f923b699b967378354e2fec77d07dda

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