django-stubs-ext

Monkey-patching and extensions for django-stubs

39 个版本 Python >=3.10
安装
pip install django-stubs-ext
poetry add django-stubs-ext
pipenv install django-stubs-ext
conda install django-stubs-ext
描述

Extensions and monkey-patching for django-stubs

test Checked with mypy StackOverflow

This package contains extensions and monkey-patching functions for the django-stubs package. Certain features of django-stubs (i.e. generic django classes that don't define the __class_getitem__ method) require runtime monkey-patching, which can't be done with type stubs. These extensions were split into a separate package so library consumers don't need mypy as a runtime dependency (#526).

Installation

pip install django-stubs-ext

Usage

In your Django application, use the following code:

import django_stubs_ext

django_stubs_ext.monkeypatch()

This only needs to be called once, so the call to monkeypatch should be placed in your top-level settings. Real-life example can be found here.

Version compatibility

Since django-stubs supports multiple Django versions, this package takes care to only monkey-patch the features needed by your django version, and decides which features to patch at runtime. This is completely safe, as (currently) we only add a __class_getitem__ method that does nothing:

@classmethod
def __class_getitem__(cls, *args, **kwargs):
    return cls

To get help

For help with django-stubs, please view the main repository at https://github.com/typeddjango/django-stubs

Contributing

The django-stubs-ext package is part of the django-stubs monorepo. If you would like to contribute, please view the django-stubs contribution guide.

You can always also reach out in gitter to discuss your contributions!

版本列表
6.0.6 2026-06-23
6.0.5 2026-05-25
6.0.4 2026-05-09
6.0.3 2026-04-18
6.0.2 2026-04-01
6.0.1 2026-03-18
6.0.0 2026-03-17
5.2.9 2026-01-20
5.2.8 2025-12-01
5.2.7 2025-10-08
5.2.6 2025-10-05
5.2.5 2025-09-12
5.2.4 2025-09-12
5.2.3 2025-09-12
5.2.2 2025-07-17
5.2.1 2025-06-17
5.2.0 2025-04-26
5.2.6a1 2025-10-05
5.1.3 2025-02-07
5.1.2 2025-01-14
5.1.1 2024-10-26
5.1.0 2024-09-23
5.0.4 2024-07-28
5.0.3 2024-07-28
5.0.2 2024-05-27
5.0.0 2024-04-30
4.2.7 2023-12-05
4.2.5 2023-10-18
4.2.2 2023-06-27
4.2.1 2023-06-02
4.2.0 2023-04-27
0.8.0 2023-03-16
0.7.0 2022-11-03
0.5.0 2022-06-17
0.4.0 2022-03-28
0.3.1 2021-09-07
0.3.0 2021-09-04
0.2.0 2021-04-14
0.1.0 2020-11-14