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 of 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.2.0.tar.gz (31.1 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.2.0-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-autotyping-0.2.0.tar.gz
  • Upload date:
  • Size: 31.1 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.2.0.tar.gz
Algorithm Hash digest
SHA256 0271146aa32f1c992d7bc5e5d96a46c0d8def651e4adc8020d35c2e8d4a2a696
MD5 eb37f41e52d97f8755f097acf6f8ec29
BLAKE2b-256 cb4d3c559c7ebdee9d10f86090f1b5d3bd4cb540755f47baea066f8d0fb73527

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_autotyping-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0af492cc5fd56160e3624fb28e58d36511169717c8099379a6c1f198f1dfa12
MD5 875e12aa7d288312f33f5e038ffb47fd
BLAKE2b-256 bc5ab70982ddf677e246f6f0c3a2778b5200865415ea10ae16970943b1b0401d

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