# Extensions and monkey-patching for django-stubs
[![Build status](https://github.com/typeddjango/django-stubs/workflows/test/badge.svg?branch=master&event=push)](https://github.com/typeddjango/django-stubs/actions?query=workflow%3Atest)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Gitter](https://badges.gitter.im/mypy-django/Lobby.svg)](https://gitter.im/mypy-django/Lobby)
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>
We have a Gitter chat here: <https://gitter.im/mypy-django/Lobby>
If you think you have a more generic typing issue, please refer to <https://github.com/python/mypy> and their Gitter.
## 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": "https://github.com/typeddjango/django-stubs",
"name": "django-stubs-ext",
"maintainer": "Marti Raudsepp",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "marti@juffo.org",
"keywords": null,
"author": "Simula Proxy",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/ca/62/a7129909d3c94eac957c02eeb05ac57cbca81db4f3f6270a8503697f376a/django_stubs_ext-5.1.1.tar.gz",
"platform": null,
"description": "# Extensions and monkey-patching for django-stubs\n\n[![Build status](https://github.com/typeddjango/django-stubs/workflows/test/badge.svg?branch=master&event=push)](https://github.com/typeddjango/django-stubs/actions?query=workflow%3Atest)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![Gitter](https://badges.gitter.im/mypy-django/Lobby.svg)](https://gitter.im/mypy-django/Lobby)\n\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\nWe have a Gitter chat here: <https://gitter.im/mypy-django/Lobby>\nIf you think you have a more generic typing issue, please refer to <https://github.com/python/mypy> and their Gitter.\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": "MIT",
"summary": "Monkey-patching and extensions for django-stubs",
"version": "5.1.1",
"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": "",
"digests": {
"blake2b_256": "6aedf79ae5ad993bdf900d61892d2a9fc0145441a507a7579890fb8e21e4a7bc",
"md5": "4640a228e4bcb176dd274226d013f99d",
"sha256": "3907f99e178c93323e2ce908aef8352adb8c047605161f8d9e5e7b4efb5a6a9c"
},
"downloads": -1,
"filename": "django_stubs_ext-5.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4640a228e4bcb176dd274226d013f99d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8965,
"upload_time": "2024-10-26T19:11:29",
"upload_time_iso_8601": "2024-10-26T19:11:29.143129Z",
"url": "https://files.pythonhosted.org/packages/6a/ed/f79ae5ad993bdf900d61892d2a9fc0145441a507a7579890fb8e21e4a7bc/django_stubs_ext-5.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ca62a7129909d3c94eac957c02eeb05ac57cbca81db4f3f6270a8503697f376a",
"md5": "430ce7ac947fdb92c4d807779fb5ae27",
"sha256": "db7364e4f50ae7e5360993dbd58a3a57ea4b2e7e5bab0fbd525ccdb3e7975d1c"
},
"downloads": -1,
"filename": "django_stubs_ext-5.1.1.tar.gz",
"has_sig": false,
"md5_digest": "430ce7ac947fdb92c4d807779fb5ae27",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9455,
"upload_time": "2024-10-26T19:11:30",
"upload_time_iso_8601": "2024-10-26T19:11:30.081366Z",
"url": "https://files.pythonhosted.org/packages/ca/62/a7129909d3c94eac957c02eeb05ac57cbca81db4f3f6270a8503697f376a/django_stubs_ext-5.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-26 19:11:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "typeddjango",
"github_project": "django-stubs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "django-stubs-ext"
}