Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: typeddjango/django-stubs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.2.1
Choose a base ref
...
head repository: typeddjango/django-stubs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.2.2
Choose a head ref
Loading
Showing with 3,742 additions and 2,206 deletions.
  1. +29 −6 .github/workflows/test.yml
  2. +1 −0 .gitignore
  3. +7 −15 .pre-commit-config.yaml
  4. +9 −19 CONTRIBUTING.md
  5. +68 −0 README.md
  6. +4 −1 django-stubs/apps/config.pyi
  7. +2 −3 django-stubs/conf/__init__.pyi
  8. +20 −3 django-stubs/conf/global_settings.pyi
  9. +1 −1 django-stubs/contrib/admin/checks.pyi
  10. +14 −3 django-stubs/contrib/admin/options.pyi
  11. +1 −1 django-stubs/contrib/admin/sites.pyi
  12. +2 −2 django-stubs/contrib/admin/utils.pyi
  13. +1 −3 django-stubs/contrib/admin/views/main.pyi
  14. +1 −1 django-stubs/contrib/admin/widgets.pyi
  15. +1 −2 django-stubs/contrib/auth/base_user.pyi
  16. +1 −1 django-stubs/contrib/auth/management/__init__.pyi
  17. +2 −2 django-stubs/contrib/auth/models.pyi
  18. +1 −1 django-stubs/contrib/contenttypes/fields.pyi
  19. +1 −1 django-stubs/contrib/contenttypes/forms.pyi
  20. +5 −5 django-stubs/contrib/contenttypes/management/__init__.pyi
  21. +1 −2 django-stubs/contrib/gis/db/backends/postgis/operations.pyi
  22. +13 −6 django-stubs/contrib/gis/db/backends/spatialite/base.pyi
  23. +1 −1 django-stubs/contrib/gis/db/models/fields.pyi
  24. +12 −0 django-stubs/contrib/gis/db/models/functions.pyi
  25. +1 −2 django-stubs/contrib/gis/gdal/layer.pyi
  26. +1 −2 django-stubs/contrib/gis/gdal/raster/band.pyi
  27. +4 −1 django-stubs/contrib/gis/gdal/raster/source.pyi
  28. +0 −2 django-stubs/contrib/gis/geos/io.pyi
  29. +0 −2 django-stubs/contrib/gis/utils/ogrinfo.pyi
  30. +0 −2 django-stubs/contrib/messages/storage/__init__.pyi
  31. +1 −1 django-stubs/contrib/postgres/constraints.pyi
  32. +1 −2 django-stubs/contrib/postgres/fields/ranges.pyi
  33. +1 −1 django-stubs/contrib/postgres/forms/array.pyi
  34. +4 −2 django-stubs/contrib/postgres/lookups.pyi
  35. +2 −1 django-stubs/contrib/postgres/operations.pyi
  36. +1 −1 django-stubs/contrib/postgres/search.pyi
  37. +3 −2 django-stubs/contrib/sessions/backends/db.pyi
  38. +3 −0 django-stubs/contrib/sitemaps/__init__.pyi
  39. +1 −1 django-stubs/contrib/sitemaps/views.pyi
  40. +7 −0 django-stubs/contrib/sites/checks.pyi
  41. +1 −1 django-stubs/contrib/sites/management.pyi
  42. +3 −3 django-stubs/contrib/sites/requests.pyi
  43. +2 −10 django-stubs/contrib/staticfiles/finders.pyi
  44. +4 −0 django-stubs/contrib/staticfiles/storage.pyi
  45. +0 −1 django-stubs/contrib/syndication/views.pyi
  46. +3 −1 django-stubs/core/cache/backends/base.pyi
  47. +7 −0 django-stubs/core/checks/compatibility/django_4_0.pyi
  48. +7 −0 django-stubs/core/checks/files.pyi
  49. +2 −0 django-stubs/core/checks/registry.pyi
  50. +10 −5 django-stubs/core/checks/security/base.pyi
  51. +2 −1 django-stubs/core/checks/security/csrf.pyi
  52. +5 −1 django-stubs/core/checks/templates.pyi
  53. +1 −2 django-stubs/core/exceptions.pyi
  54. +1 −1 django-stubs/core/files/storage/mixins.pyi
  55. +1 −1 django-stubs/core/files/uploadedfile.pyi
  56. +2 −0 django-stubs/core/mail/backends/console.pyi
  57. +1 −1 django-stubs/core/mail/message.pyi
  58. +1 −2 django-stubs/core/management/base.pyi
  59. +0 −2 django-stubs/core/paginator.pyi
  60. +1 −1 django-stubs/core/serializers/base.pyi
  61. +1 −1 django-stubs/core/serializers/xml_serializer.pyi
  62. +1 −6 django-stubs/core/validators.pyi
  63. +0 −1 django-stubs/db/backends/base/features.pyi
  64. +2 −2 django-stubs/db/backends/base/introspection.pyi
  65. +20 −14 django-stubs/db/backends/base/operations.pyi
  66. +0 −1 django-stubs/db/backends/dummy/base.pyi
  67. +1 −2 django-stubs/db/backends/mysql/base.pyi
  68. +1 −1 django-stubs/db/backends/mysql/client.pyi
  69. +0 −8 django-stubs/db/backends/mysql/introspection.pyi
  70. +9 −8 django-stubs/db/backends/mysql/operations.pyi
  71. +0 −9 django-stubs/db/backends/oracle/introspection.pyi
  72. +7 −7 django-stubs/db/backends/oracle/operations.pyi
  73. +0 −7 django-stubs/db/backends/postgresql/introspection.pyi
  74. +8 −0 django-stubs/db/backends/postgresql/operations.pyi
  75. +0 −581 django-stubs/db/backends/postgresql/test_import_all.yml
  76. +17 −1 django-stubs/db/backends/sqlite3/operations.pyi
  77. +2 −2 django-stubs/db/backends/utils.pyi
  78. +1 −1 django-stubs/db/migrations/graph.pyi
  79. +1 −0 django-stubs/db/migrations/operations/__init__.pyi
  80. +2 −0 django-stubs/db/migrations/operations/base.pyi
  81. +5 −4 django-stubs/db/migrations/operations/fields.pyi
  82. +25 −7 django-stubs/db/migrations/operations/models.pyi
  83. +12 −8 django-stubs/db/migrations/operations/special.pyi
  84. +1 −1 django-stubs/db/migrations/operations/utils.pyi
  85. +35 −10 django-stubs/db/migrations/state.pyi
  86. +1 −2 django-stubs/db/models/base.pyi
  87. +6 −0 django-stubs/db/models/constants.pyi
  88. +3 −3 django-stubs/db/models/constraints.pyi
  89. +1 −1 django-stubs/db/models/deletion.pyi
  90. +2 −0 django-stubs/db/models/enums.pyi
  91. +32 −21 django-stubs/db/models/expressions.pyi
  92. +5 −7 django-stubs/db/models/fields/__init__.pyi
  93. +11 −2 django-stubs/db/models/fields/json.pyi
  94. +2 −2 django-stubs/db/models/fields/related.pyi
  95. +1 −2 django-stubs/db/models/fields/related_descriptors.pyi
  96. +1 −2 django-stubs/db/models/fields/reverse_related.pyi
  97. +2 −3 django-stubs/db/models/lookups.pyi
  98. +9 −2 django-stubs/db/models/options.pyi
  99. +2 −0 django-stubs/db/models/query.pyi
  100. +1 −2 django-stubs/db/models/query_utils.pyi
  101. +0 −1 django-stubs/db/models/signals.pyi
  102. +3 −2 django-stubs/db/models/sql/compiler.pyi
  103. +1 −4 django-stubs/db/models/sql/constants.pyi
  104. +4 −5 django-stubs/db/models/sql/query.pyi
  105. +0 −1 django-stubs/db/models/sql/subqueries.pyi
  106. +25 −12 django-stubs/dispatch/dispatcher.pyi
  107. +1 −1 django-stubs/forms/fields.pyi
  108. +8 −1 django-stubs/forms/models.pyi
  109. +2 −2 django-stubs/forms/widgets.pyi
  110. +1 −4 django-stubs/http/multipartparser.pyi
  111. +2 −2 django-stubs/http/request.pyi
  112. +2 −3 django-stubs/http/response.pyi
  113. +1 −1 django-stubs/middleware/cache.pyi
  114. +1 −2 django-stubs/shortcuts.pyi
  115. +0 −1 django-stubs/template/backends/base.pyi
  116. +0 −1 django-stubs/template/base.pyi
  117. +1 −1 django-stubs/template/context.pyi
  118. +1 −1 django-stubs/template/loader_tags.pyi
  119. +150 −28 django-stubs/test/client.pyi
  120. +2 −3 django-stubs/test/runner.pyi
  121. +3 −3 django-stubs/test/utils.pyi
  122. +1 −2 django-stubs/urls/base.pyi
  123. +7 −3 django-stubs/urls/resolvers.pyi
  124. +1 −1 django-stubs/utils/asyncio.pyi
  125. +2 −0 django-stubs/utils/autoreload.pyi
  126. +6 −3 django-stubs/utils/connection.pyi
  127. +3 −2 django-stubs/utils/crypto.pyi
  128. +11 −8 django-stubs/utils/datastructures.pyi
  129. +1 −2 django-stubs/utils/dateformat.pyi
  130. +1 −2 django-stubs/utils/dateparse.pyi
  131. +7 −3 django-stubs/utils/datetime_safe.pyi
  132. +2 −9 django-stubs/utils/decorators.pyi
  133. +15 −7 django-stubs/utils/deprecation.pyi
  134. +2 −8 django-stubs/utils/encoding.pyi
  135. +3 −2 django-stubs/utils/feedgenerator.pyi
  136. +3 −3 django-stubs/utils/formats.pyi
  137. +15 −7 django-stubs/utils/functional.pyi
  138. +35 −10 django-stubs/utils/html.pyi
  139. +1 −14 django-stubs/utils/http.pyi
  140. +1 −1 django-stubs/utils/log.pyi
  141. +1 −0 django-stubs/utils/module_loading.pyi
  142. +2 −4 django-stubs/utils/text.pyi
  143. +3 −2 django-stubs/utils/timesince.pyi
  144. +2 −2 django-stubs/utils/timezone.pyi
  145. +0 −31 django-stubs/utils/translation/__init__.pyi
  146. +3 −1 django-stubs/utils/translation/template.pyi
  147. +0 −2 django-stubs/utils/translation/trans_null.pyi
  148. +5 −3 django-stubs/utils/translation/trans_real.pyi
  149. +5 −1 django-stubs/utils/tree.pyi
  150. +2 −1 django-stubs/utils/version.pyi
  151. +5 −3 django-stubs/views/debug.pyi
  152. +1 −2 django-stubs/views/generic/edit.pyi
  153. +1 −1 django-stubs/views/generic/list.pyi
  154. +32 −0 django_stubs_ext/django_stubs_ext/db/router.py
  155. +2 −0 django_stubs_ext/django_stubs_ext/patch.py
  156. +1 −4 django_stubs_ext/setup.py
  157. +15 −11 mypy.ini
  158. +25 −6 mypy_django_plugin/config.py
  159. +31 −17 mypy_django_plugin/django/context.py
  160. +2 −0 mypy_django_plugin/exceptions.py
  161. +25 −9 mypy_django_plugin/lib/helpers.py
  162. +43 −35 mypy_django_plugin/main.py
  163. +5 −4 mypy_django_plugin/transformers/fields.py
  164. +1 −2 mypy_django_plugin/transformers/forms.py
  165. +1 −2 mypy_django_plugin/transformers/functional.py
  166. +1 −2 mypy_django_plugin/transformers/managers.py
  167. +1 −2 mypy_django_plugin/transformers/meta.py
  168. +32 −35 mypy_django_plugin/transformers/models.py
  169. +6 −3 mypy_django_plugin/transformers/orm_lookups.py
  170. +1 −4 mypy_django_plugin/transformers/querysets.py
  171. +1 −2 mypy_django_plugin/transformers/request.py
  172. +12 −3 mypy_django_plugin/transformers/settings.py
  173. +18 −6 pyproject.toml
  174. +4 −6 requirements.txt
  175. +2 −237 scripts/django_tests_settings.py
  176. +0 −539 scripts/enabled_test_modules.py
  177. +0 −34 scripts/git_helpers.py
  178. +0 −4 scripts/paths.py
  179. +0 −15 scripts/stubgen-django.py
  180. +14 −0 scripts/stubtest.sh
  181. +76 −0 scripts/stubtest/allowlist.txt
  182. +2,411 −0 scripts/stubtest/allowlist_todo.txt
  183. +0 −123 scripts/typecheck_tests.py
  184. +4 −6 setup.py
  185. +31 −7 tests/test_error_handling.py
  186. +5 −2 tests/typecheck/contrib/auth/test_misc.yml
  187. +1 −1 tests/typecheck/db/migrations/test_operations.yml
  188. +32 −0 tests/typecheck/fields/test_related.yml
  189. +39 −0 tests/typecheck/test_settings.yml
  190. +1 −1 tests/typecheck/utils/test_functional.yml
35 changes: 29 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9']
python-version: ['3.11']
steps:
- uses: actions/checkout@v3
- name: Setup system dependencies
@@ -64,15 +64,36 @@ jobs:
- name: Run tests
run: PYTHONPATH='.' pytest

typecheck:
stubtest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v3
- name: Setup system dependencies
run: |
sudo apt-get update
sudo apt-get install binutils libproj-dev gdal-bin
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U pip setuptools wheel
pip install -r ./requirements.txt
- name: Run stubtest
run: bash ./scripts/stubtest.sh

matrix-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
django-version: ['3.2', '4.2']
include:
- python-version: '3.8'
django-version: '2.2'
- python-version: '3.11'
django-version: '4.1'
steps:
@@ -89,6 +110,8 @@ jobs:
run: |
pip install -U pip setuptools wheel
pip install -r ./requirements.txt
pip install "Django==${{ matrix.django-version }}"
pip check
- name: Run tests
run: python ./scripts/typecheck_tests.py --django_version="${{ matrix.django-version }}"
- name: Run django-stubs-ext tests
run: PYTHONPATH='.' pytest django_stubs_ext
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
.idea/
.mypy_cache/
.pytest_cache/
.ruff_cache/
.venv/
__pycache__/
django-source/
22 changes: 7 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.9
python: python3.11
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
@@ -12,19 +12,11 @@ repos:
- id: debug-statements
- id: check-merge-conflict
- id: end-of-file-fixer
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.275
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (pyi)
types: [pyi]
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
@@ -34,8 +26,8 @@ repos:
hooks:
- id: flake8
additional_dependencies:
- flake8-no-pep420==2.4.0
- flake8-pyi==22.11.0
- flake8-no-pep420==2.6.0
- flake8-pyi==23.5.0
types: []
files: ^.*.pyi?$

28 changes: 9 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ This project is open source and community driven. As such we encourage code cont
3. Improve plugin code and extend its capabilities
4. Write tests
5. Update dependencies
6. Fix and remove things from our `scripts/stubtest/allowlist_todo.txt`

## Tutorials

@@ -76,30 +77,19 @@ If you get some unexpected results or want to be sure that tests run is not affe
rm -r .mypy_cache
```

We also test the stubs against Django's own test suite. This is done in CI but you can also do this locally.
To execute the script run:

```bash
python ./scripts/typecheck_tests.py --django_version 3.2
```
### Testing stubs with `stubtest`

Run `bash ./scripts/stubtest.sh` to test that stubs and sources are in-line.

### Generating Stubs using Stubgen
We have two special files to allow errors:
1. `scripts/stubtest/allowlist.txt` where we store things that we really don't care about: hacks, django internal utility modules, things that are handled by our plugin, things that are not representable by type system, etc
2. `scripts/stubtest/allowlist_todo.txt` where we store all errors there are right now. Basically, this is a TODO list: we need to work through this list and fix things (or move entries to real `allowlist.txt`). In the end, ideally we can remove this file

The stubs are based on auto-generated code created by Mypy's stubgen tool (see: [the stubgen docs](https://mypy.readthedocs.io/en/stable/stubgen.html)).
To make life easier we have a helper script that auto generates these stubs. To use it you can run:
You might also want to disable `incremental` mode while working on `stubtest` changes.
This mode leads to several known problems (stubs do not show up or have strange errors).

```bash
python ./scripts/stubgen-django.py --django_version 3.2
```

You can also pass an optional commit hash as a second kwarg to checkout a specific commit, e.g.

```bash
python ./scripts/stubgen-django.py --django_version 3.2 --commit_sha <commit_sha>
```
**Important**: right now we only run `stubtest` on Python 3.11 (because it is the latest released version at the moment), any other versions might generate different outputs. Any work to create per-version allowlists is welcome.

The output for this is a gitignored folder called "stubgen" in the repo's root.

## Submission Guidelines

68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ We rely on different `django` and `mypy` versions:

| django-stubs | Mypy version | Django version | Django partial support | Python version |
|----------------|--------------|----------------|------------------------|----------------|
| 4.2.2 | 1.4.x | 4.2 | 4.1, 3.2 | 3.8 - 3.11 |
| 4.2.1 | 1.3.x | 4.2 | 4.1, 3.2 | 3.8 - 3.11 |
| 4.2.0 | 1.2.x | 4.2 | 4.1, 4.0, 3.2 | 3.7 - 3.11 |
| 1.16.0 | 1.1.x | 4.1 | 4.0, 3.2 | 3.7 - 3.11 |
@@ -76,6 +77,26 @@ class MyModel(models.Model):
]
```

### Other typed base classes

* `django_stubs_ext.db.router.TypedDatabaseRouter` can be used as base when implementing custom database routers.

## Settings

django-stubs has a few settings, which you can list in:

* `pyproject.toml`, under the table `[tool.django-stubs]`
* `mypy.ini` under the table `[mypy.plugins.django-stubs]`

The supported settings are:

- `django_settings_module`, a string.

Specify the import path of your settings module, the same as Django’s [`DJANGO_SETTINGS_MODULE` environment variable](https://docs.djangoproject.com/en/stable/topics/settings/#designating-the-settings).

- `strict_settings`, a boolean, default `true`.

Set to `false` if using dynamic settings, as [described below](https://github.com/typeddjango/django-stubs#how-to-use-a-custom-library-to-handle-django-settings).

## FAQ

@@ -308,6 +329,53 @@ If you encounter this error in your own code, you can either cast the `Promise`

If this is reported on Django code, please report an issue or open a pull request to fix the type hints.

### How to use a custom library to handle Django settings?

Using something like [`django-split-settings`](https://github.com/wemake-services/django-split-settings) or [`django-configurations`](https://github.com/jazzband/django-configurations) will make it hard for mypy to infer your settings.

This might also be the case when using something like:

```python
try:
from .local_settings import *
except Exception:
pass
```

So, mypy would not like this code:

```python
from django.conf import settings

settings.CUSTOM_VALUE # E: 'Settings' object has no attribute 'CUSTOM_SETTING'
```

To handle this corner case we have a special setting `strict_settings` (`True` by default),
you can switch it to `False` to always return `Any` and not raise any errors if runtime settings module has the given value,
for example `pyproject.toml`:

```toml
[tool.django-stubs]
strict_settings = false
```

or `mypy.ini`:

```ini
[mypy.plugins.django-stubs]
strict_settings = false
```

And then:

```python
# Works:
reveal_type(settings.EXISTS_IN_RUNTIME) # N: Any

# Errors:
reveal_type(settings.MISSING) # E: 'Settings' object has no attribute 'MISSING'
```

## Related projects

- [`awesome-python-typing`](https://github.com/typeddjango/awesome-python-typing) - Awesome list of all typing-related things in Python.
5 changes: 4 additions & 1 deletion django-stubs/apps/config.pyi
Original file line number Diff line number Diff line change
@@ -3,8 +3,9 @@ from collections.abc import Iterator

from django.apps.registry import Apps
from django.db.models.base import Model
from django.utils.functional import _StrOrPromise
from django.utils.functional import _StrOrPromise, cached_property

APPS_MODULE_NAME: str
MODELS_MODULE_NAME: str

class AppConfig:
@@ -17,6 +18,8 @@ class AppConfig:
models_module: str | None
models: dict[str, type[Model]]
def __init__(self, app_name: str, app_module: types.ModuleType | None) -> None: ...
@cached_property
def default_auto_field(self) -> str: ...
@classmethod
def create(cls, entry: str) -> AppConfig: ...
def get_model(self, model_name: str, require_ready: bool = ...) -> type[Model]: ...
5 changes: 2 additions & 3 deletions django-stubs/conf/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from typing import Any
from typing import Any, Literal

from _typeshed import Self
from django.utils.functional import LazyObject
from typing_extensions import Literal

# explicit dependency on standard settings to make it loaded
from . import global_settings
from . import global_settings # noqa: F401

ENVIRONMENT_VARIABLE: Literal["DJANGO_SETTINGS_MODULE"]
DEFAULT_STORAGE_ALIAS: Literal["default"]
23 changes: 20 additions & 3 deletions django-stubs/conf/global_settings.pyi
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@ from re import Pattern

# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
from typing import Any, Protocol
from typing import Any, Literal, Protocol

from typing_extensions import Literal, TypeAlias
from typing_extensions import TypeAlias

_Admins: TypeAlias = list[tuple[str, str]]

@@ -40,6 +40,7 @@ TIME_ZONE: str

# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ: bool
USE_DEPRECATED_PYTZ: bool

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
@@ -210,6 +211,10 @@ DATA_UPLOAD_MAX_MEMORY_SIZE: int # i.e. 2.5 MB
# SuspiciousOperation (TooManyFieldsSent) is raised.
DATA_UPLOAD_MAX_NUMBER_FIELDS: int

# Maximum number of files encoded in a multipart upload that will be read
# before a SuspiciousOperation (TooManyFilesSent) is raised.
DATA_UPLOAD_MAX_NUMBER_FILES: int

# Directory in which upload streamed files will be temporarily saved. A value of
# `None` will make Django use the operating system's default temporary directory
# (i.e. "/tmp" on *nix systems).
@@ -301,6 +306,9 @@ THOUSAND_SEPARATOR: str
DEFAULT_TABLESPACE: str
DEFAULT_INDEX_TABLESPACE: str

# Default primary key field type.
DEFAULT_AUTO_FIELD: str

# Default X-Frame-Options header value
X_FRAME_OPTIONS: str

@@ -425,6 +433,10 @@ CSRF_HEADER_NAME: str
CSRF_TRUSTED_ORIGINS: list[str]
CSRF_USE_SESSIONS: bool

# Whether to mask CSRF cookie value. It's a transitional setting helpful in
# migrating multiple instance of the same project to Django 4.1+.
CSRF_COOKIE_MASKED: bool

############
# MESSAGES #
############
@@ -445,6 +457,10 @@ LOGGING_CONFIG: str
# Custom logging configuration.
LOGGING: dict[str, Any]

# Default exception reporter class used in case none has been
# specifically assigned to the HttpRequest instance.
DEFAULT_EXCEPTION_REPORTER: str

# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
DEFAULT_EXCEPTION_REPORTER_FILTER: str
@@ -501,11 +517,12 @@ SILENCED_SYSTEM_CHECKS: list[str]
#######################
# SECURITY MIDDLEWARE #
#######################
SECURE_BROWSER_XSS_FILTER: bool
SECURE_CONTENT_TYPE_NOSNIFF: bool
SECURE_CROSS_ORIGIN_OPENER_POLICY: str
SECURE_HSTS_INCLUDE_SUBDOMAINS: bool
SECURE_HSTS_PRELOAD: bool
SECURE_HSTS_SECONDS: int
SECURE_REDIRECT_EXEMPT: list[str]
SECURE_REFERRER_POLICY: str
SECURE_SSL_HOST: str | None
SECURE_SSL_REDIRECT: bool
2 changes: 1 addition & 1 deletion django-stubs/contrib/admin/checks.pyi
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ from typing import Any

from django.apps.config import AppConfig
from django.contrib.admin.options import BaseModelAdmin
from django.core.checks.messages import CheckMessage, Error
from django.core.checks.messages import CheckMessage

def check_admin_app(app_configs: Sequence[AppConfig] | None, **kwargs: Any) -> list[CheckMessage]: ...
def check_dependencies(**kwargs: Any) -> list[CheckMessage]: ...
Loading