django-stubs-ext


Namedjango-stubs-ext JSON
Version 5.2.5 PyPI version JSON
download
home_pageNone
SummaryMonkey-patching and extensions for django-stubs
upload_time2025-09-12 19:29:06
maintainerNone
docs_urlNone
authorSimula Proxy
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Extensions and monkey-patching for django-stubs

[![test](https://github.com/typeddjango/django-stubs/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/typeddjango/django-stubs/actions/workflows/test.yml)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![StackOverflow](https://shields.io/badge/ask-stackoverflow-orange?logo=stackoverflow)](https://stackoverflow.com/questions/tagged/django-stubs?tab=Active)

This package contains extensions and monkey-patching functions for the [django-stubs](https://github.com/typeddjango/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](https://github.com/typeddjango/django-stubs/pull/526#pullrequestreview-525798031)).

## Installation

```bash
pip install django-stubs-ext
```

## Usage

In your Django application, use the following code:

```py
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](https://github.com/wemake-services/wemake-django-template/blob/5bf1569e2710e11befc6991893f94419136d74bd/%7B%7Bcookiecutter.project_name%7D%7D/server/settings/__init__.py#L14-L19).

## 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:

```py
@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](https://github.com/typeddjango/django-stubs) monorepo. If you would like to contribute, please view the django-stubs [contribution guide](https://github.com/typeddjango/django-stubs/blob/master/CONTRIBUTING.md).

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-stubs-ext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Marti Raudsepp <marti@juffo.org>, Nikita Sobolev <mail@sobolevn.me>, Petter Friberg <petter_friberg@hotmail.com>, Adam Johnson <me@adamj.eu>",
    "keywords": null,
    "author": "Simula Proxy",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/16/94/c9b8f4c47084a0fa666da9066c36771098101932688adf2c17a40fab79c2/django_stubs_ext-5.2.5.tar.gz",
    "platform": null,
    "description": "# Extensions and monkey-patching for django-stubs\n\n[![test](https://github.com/typeddjango/django-stubs/actions/workflows/test.yml/badge.svg?branch=master&event=push)](https://github.com/typeddjango/django-stubs/actions/workflows/test.yml)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![StackOverflow](https://shields.io/badge/ask-stackoverflow-orange?logo=stackoverflow)](https://stackoverflow.com/questions/tagged/django-stubs?tab=Active)\n\nThis package contains extensions and monkey-patching functions for the [django-stubs](https://github.com/typeddjango/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](https://github.com/typeddjango/django-stubs/pull/526#pullrequestreview-525798031)).\n\n## Installation\n\n```bash\npip install django-stubs-ext\n```\n\n## Usage\n\nIn your Django application, use the following code:\n\n```py\nimport django_stubs_ext\n\ndjango_stubs_ext.monkeypatch()\n```\n\nThis only needs to be called once, so the call to `monkeypatch` should be placed in your top-level settings.\nReal-life example [can be found here](https://github.com/wemake-services/wemake-django-template/blob/5bf1569e2710e11befc6991893f94419136d74bd/%7B%7Bcookiecutter.project_name%7D%7D/server/settings/__init__.py#L14-L19).\n\n## Version compatibility\n\nSince 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:\n\n```py\n@classmethod\ndef __class_getitem__(cls, *args, **kwargs):\n    return cls\n```\n\n## To get help\n\nFor help with django-stubs, please view the main repository at <https://github.com/typeddjango/django-stubs>\n\n## Contributing\n\nThe django-stubs-ext package is part of the [django-stubs](https://github.com/typeddjango/django-stubs) monorepo. If you would like to contribute, please view the django-stubs [contribution guide](https://github.com/typeddjango/django-stubs/blob/master/CONTRIBUTING.md).\n\nYou can always also reach out in gitter to discuss your contributions!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Monkey-patching and extensions for django-stubs",
    "version": "5.2.5",
    "project_urls": {
        "Funding": "https://github.com/sponsors/typeddjango",
        "Homepage": "https://github.com/typeddjango/django-stubs",
        "Release notes": "https://github.com/typeddjango/django-stubs/releases"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e0fea85a105fddffadb4a8d50e500caeee87d836b679d51a19d52dfa0cc6c660",
                "md5": "07f71b02021d6fd9bc1bb552ff37bd3e",
                "sha256": "9b4b8ac9d32f7e6c304fd05477f8688fae6ed57f6a0f9f4d074f9e55b5a3da14"
            },
            "downloads": -1,
            "filename": "django_stubs_ext-5.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "07f71b02021d6fd9bc1bb552ff37bd3e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9310,
            "upload_time": "2025-09-12T19:29:04",
            "upload_time_iso_8601": "2025-09-12T19:29:04.620824Z",
            "url": "https://files.pythonhosted.org/packages/e0/fe/a85a105fddffadb4a8d50e500caeee87d836b679d51a19d52dfa0cc6c660/django_stubs_ext-5.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1694c9b8f4c47084a0fa666da9066c36771098101932688adf2c17a40fab79c2",
                "md5": "665b76dfcbfff108ce52e8f91cf98656",
                "sha256": "ecc628df29d36cede638567c4e33ff485dd7a99f1552ad0cece8c60e9c3a8872"
            },
            "downloads": -1,
            "filename": "django_stubs_ext-5.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "665b76dfcbfff108ce52e8f91cf98656",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 6489,
            "upload_time": "2025-09-12T19:29:06",
            "upload_time_iso_8601": "2025-09-12T19:29:06.008149Z",
            "url": "https://files.pythonhosted.org/packages/16/94/c9b8f4c47084a0fa666da9066c36771098101932688adf2c17a40fab79c2/django_stubs_ext-5.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-12 19:29:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sponsors",
    "github_project": "typeddjango",
    "github_not_found": true,
    "lcname": "django-stubs-ext"
}
        
Elapsed time: 1.18104s