django-types 0.19.1__py3-none-any.whl → 0.21.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. django-stubs/contrib/admin/__init__.pyi +1 -0
  2. django-stubs/contrib/admin/actions.pyi +2 -2
  3. django-stubs/contrib/admin/decorators.pyi +4 -3
  4. django-stubs/contrib/admin/filters.pyi +5 -5
  5. django-stubs/contrib/admin/models.pyi +23 -11
  6. django-stubs/contrib/admin/options.pyi +67 -38
  7. django-stubs/contrib/admin/sites.pyi +11 -11
  8. django-stubs/contrib/admin/templatetags/base.pyi +1 -1
  9. django-stubs/contrib/admin/utils.pyi +2 -2
  10. django-stubs/contrib/admin/views/autocomplete.pyi +2 -2
  11. django-stubs/contrib/admin/views/main.pyi +8 -7
  12. django-stubs/contrib/admindocs/middleware.pyi +2 -2
  13. django-stubs/contrib/auth/__init__.pyi +14 -4
  14. django-stubs/contrib/auth/admin.pyi +2 -2
  15. django-stubs/contrib/auth/backends.pyi +22 -0
  16. django-stubs/contrib/auth/base_user.pyi +3 -3
  17. django-stubs/contrib/auth/forms.pyi +1 -1
  18. django-stubs/contrib/auth/middleware.pyi +1 -2
  19. django-stubs/contrib/auth/models.pyi +50 -26
  20. django-stubs/contrib/auth/views.pyi +1 -2
  21. django-stubs/contrib/contenttypes/fields.pyi +1 -1
  22. django-stubs/contrib/contenttypes/models.pyi +3 -1
  23. django-stubs/contrib/flatpages/middleware.pyi +2 -2
  24. django-stubs/contrib/flatpages/views.pyi +3 -3
  25. django-stubs/contrib/postgres/fields/array.pyi +6 -5
  26. django-stubs/contrib/postgres/fields/citext.pyi +13 -8
  27. django-stubs/contrib/postgres/fields/hstore.pyi +5 -4
  28. django-stubs/contrib/staticfiles/finders.pyi +1 -2
  29. django-stubs/contrib/staticfiles/views.pyi +2 -2
  30. django-stubs/contrib/syndication/views.pyi +4 -4
  31. django-stubs/core/cache/backends/base.pyi +9 -0
  32. django-stubs/core/exceptions.pyi +18 -11
  33. django-stubs/core/files/base.pyi +1 -1
  34. django-stubs/core/files/storage.pyi +2 -2
  35. django-stubs/core/mail/__init__.pyi +1 -1
  36. django-stubs/core/mail/backends/base.pyi +1 -0
  37. django-stubs/core/mail/message.pyi +6 -6
  38. django-stubs/core/serializers/json.pyi +1 -1
  39. django-stubs/core/servers/basehttp.pyi +2 -2
  40. django-stubs/db/backends/utils.pyi +1 -2
  41. django-stubs/db/migrations/recorder.pyi +1 -1
  42. django-stubs/db/models/base.pyi +9 -3
  43. django-stubs/db/models/constraints.pyi +1 -0
  44. django-stubs/db/models/enums.pyi +10 -19
  45. django-stubs/db/models/expressions.pyi +1 -1
  46. django-stubs/db/models/fields/__init__.pyi +227 -77
  47. django-stubs/db/models/fields/files.pyi +2 -2
  48. django-stubs/db/models/fields/json.pyi +10 -6
  49. django-stubs/db/models/fields/related.pyi +42 -20
  50. django-stubs/db/models/fields/related_descriptors.pyi +3 -3
  51. django-stubs/db/models/functions/__init__.pyi +2 -0
  52. django-stubs/db/models/functions/comparison.pyi +8 -0
  53. django-stubs/db/models/manager.pyi +11 -6
  54. django-stubs/db/models/query.pyi +4 -1
  55. django-stubs/db/models/query_utils.pyi +1 -0
  56. django-stubs/db/transaction.pyi +7 -1
  57. django-stubs/forms/boundfield.pyi +3 -1
  58. django-stubs/forms/forms.pyi +28 -35
  59. django-stubs/forms/formsets.pyi +98 -63
  60. django-stubs/forms/models.pyi +22 -17
  61. django-stubs/forms/renderers.pyi +26 -13
  62. django-stubs/forms/utils.pyi +38 -11
  63. django-stubs/http/cookie.pyi +3 -1
  64. django-stubs/http/request.pyi +43 -16
  65. django-stubs/http/response.pyi +38 -30
  66. django-stubs/shortcuts.pyi +1 -2
  67. django-stubs/template/backends/base.pyi +14 -5
  68. django-stubs/template/backends/django.pyi +24 -3
  69. django-stubs/template/backends/dummy.pyi +7 -6
  70. django-stubs/template/backends/jinja2.pyi +20 -2
  71. django-stubs/template/backends/utils.pyi +3 -3
  72. django-stubs/template/base.pyi +2 -2
  73. django-stubs/template/context.pyi +2 -2
  74. django-stubs/template/context_processors.pyi +1 -2
  75. django-stubs/template/library.pyi +79 -15
  76. django-stubs/template/loader.pyi +5 -3
  77. django-stubs/template/response.pyi +3 -3
  78. django-stubs/template/utils.pyi +6 -4
  79. django-stubs/test/client.pyi +176 -20
  80. django-stubs/test/testcases.pyi +4 -4
  81. django-stubs/test/utils.pyi +41 -55
  82. django-stubs/urls/base.pyi +18 -2
  83. django-stubs/urls/conf.pyi +7 -0
  84. django-stubs/utils/cache.pyi +4 -4
  85. django-stubs/utils/datastructures.pyi +5 -5
  86. django-stubs/utils/deconstruct.pyi +10 -2
  87. django-stubs/utils/log.pyi +1 -1
  88. django-stubs/utils/six.pyi +1 -1
  89. django-stubs/utils/translation/__init__.pyi +5 -3
  90. django-stubs/utils/translation/trans_real.pyi +2 -2
  91. django-stubs/views/decorators/csrf.pyi +1 -1
  92. django-stubs/views/generic/edit.pyi +1 -2
  93. {django_types-0.19.1.dist-info → django_types-0.21.0.dist-info}/METADATA +12 -8
  94. {django_types-0.19.1.dist-info → django_types-0.21.0.dist-info}/RECORD +96 -96
  95. {django_types-0.19.1.dist-info → django_types-0.21.0.dist-info}/WHEEL +1 -1
  96. {django_types-0.19.1.dist-info → django_types-0.21.0.dist-info}/LICENSE.txt +0 -0
@@ -1,3 +1,4 @@
1
+ from collections.abc import Mapping
1
2
  from io import BytesIO
2
3
  from json import JSONEncoder
3
4
  from re import Pattern
@@ -36,6 +37,13 @@ class ClientHandler(BaseHandler):
36
37
  ) -> None: ...
37
38
  def __call__(self, environ: dict[str, Any]) -> HttpResponseBase: ...
38
39
 
40
+ class AsyncClientHandler(BaseHandler):
41
+ enforce_csrf_checks: bool = ...
42
+ def __init__(
43
+ self, enforce_csrf_checks: bool = ..., *args: Any, **kwargs: Any
44
+ ) -> None: ...
45
+ async def __call__(self, scope: dict[str, Any]) -> HttpResponseBase: ...
46
+
39
47
  def encode_multipart(boundary: str, data: dict[str, Any]) -> bytes: ...
40
48
  def encode_file(boundary: str, key: str, file: Any) -> list[bytes]: ...
41
49
 
@@ -44,10 +52,14 @@ _RequestData = Any | None
44
52
  class RequestFactory:
45
53
  json_encoder: type[JSONEncoder]
46
54
  defaults: dict[str, str]
47
- cookies: SimpleCookie[str]
55
+ cookies: SimpleCookie # type: ignore [type-arg]
48
56
  errors: BytesIO
49
57
  def __init__(
50
- self, *, json_encoder: type[JSONEncoder] = ..., **defaults: Any
58
+ self,
59
+ *,
60
+ json_encoder: type[JSONEncoder] = ...,
61
+ headers: Mapping[str, Any] | None = ...,
62
+ **defaults: Any,
51
63
  ) -> None: ...
52
64
  def request(self, **request: Any) -> WSGIRequest: ...
53
65
  def get(
@@ -57,7 +69,8 @@ class RequestFactory:
57
69
  secure: bool = ...,
58
70
  *,
59
71
  QUERY_STRING: str = ...,
60
- **extra: str
72
+ headers: Mapping[str, Any] | None = ...,
73
+ **extra: object,
61
74
  ) -> WSGIRequest: ...
62
75
  def post(
63
76
  self,
@@ -67,7 +80,8 @@ class RequestFactory:
67
80
  secure: bool = ...,
68
81
  *,
69
82
  QUERY_STRING: str = ...,
70
- **extra: str
83
+ headers: Mapping[str, Any] | None = ...,
84
+ **extra: object,
71
85
  ) -> WSGIRequest: ...
72
86
  def head(
73
87
  self,
@@ -76,10 +90,17 @@ class RequestFactory:
76
90
  secure: bool = ...,
77
91
  *,
78
92
  QUERY_STRING: str = ...,
79
- **extra: str
93
+ headers: Mapping[str, Any] | None = ...,
94
+ **extra: object,
80
95
  ) -> WSGIRequest: ...
81
96
  def trace(
82
- self, path: str, secure: bool = ..., *, QUERY_STRING: str = ..., **extra: str
97
+ self,
98
+ path: str,
99
+ secure: bool = ...,
100
+ *,
101
+ QUERY_STRING: str = ...,
102
+ headers: Mapping[str, Any] | None = ...,
103
+ **extra: object,
83
104
  ) -> WSGIRequest: ...
84
105
  def options(
85
106
  self,
@@ -89,7 +110,8 @@ class RequestFactory:
89
110
  secure: bool = ...,
90
111
  *,
91
112
  QUERY_STRING: str = ...,
92
- **extra: str
113
+ headers: Mapping[str, Any] | None = ...,
114
+ **extra: object,
93
115
  ) -> WSGIRequest: ...
94
116
  def put(
95
117
  self,
@@ -99,7 +121,8 @@ class RequestFactory:
99
121
  secure: bool = ...,
100
122
  *,
101
123
  QUERY_STRING: str = ...,
102
- **extra: str
124
+ headers: Mapping[str, Any] | None = ...,
125
+ **extra: object,
103
126
  ) -> WSGIRequest: ...
104
127
  def patch(
105
128
  self,
@@ -109,7 +132,8 @@ class RequestFactory:
109
132
  secure: bool = ...,
110
133
  *,
111
134
  QUERY_STRING: str = ...,
112
- **extra: str
135
+ headers: Mapping[str, Any] | None = ...,
136
+ **extra: object,
113
137
  ) -> WSGIRequest: ...
114
138
  def delete(
115
139
  self,
@@ -119,7 +143,8 @@ class RequestFactory:
119
143
  secure: bool = ...,
120
144
  *,
121
145
  QUERY_STRING: str = ...,
122
- **extra: str
146
+ headers: Mapping[str, Any] | None = ...,
147
+ **extra: object,
123
148
  ) -> WSGIRequest: ...
124
149
  def generic(
125
150
  self,
@@ -130,20 +155,23 @@ class RequestFactory:
130
155
  secure: bool = ...,
131
156
  *,
132
157
  QUERY_STRING: str = ...,
133
- **extra: str
158
+ headers: Mapping[str, Any] | None = ...,
159
+ **extra: object,
134
160
  ) -> WSGIRequest: ...
135
161
 
136
162
  class Client(RequestFactory):
137
163
  handler: ClientHandler
138
164
  raise_request_exception: bool
139
165
  exc_info: tuple[type[BaseException], BaseException, TracebackType] | None
166
+ headers: dict[str, Any]
140
167
  def __init__(
141
168
  self,
142
169
  enforce_csrf_checks: bool = ...,
143
170
  raise_request_exception: bool = ...,
144
171
  *,
145
172
  json_encoder: type[JSONEncoder] = ...,
146
- **defaults: Any
173
+ headers: Mapping[str, Any] | None = ...,
174
+ **defaults: Any,
147
175
  ) -> None: ...
148
176
  # Silence type warnings, since this class overrides arguments and return types in an unsafe manner.
149
177
  def request(self, **request: Any) -> HttpResponse: ... # type: ignore [override]
@@ -155,7 +183,8 @@ class Client(RequestFactory):
155
183
  secure: bool = ...,
156
184
  *,
157
185
  QUERY_STRING: str = ...,
158
- **extra: str
186
+ headers: Mapping[str, Any] | None = ...,
187
+ **extra: str,
159
188
  ) -> HttpResponse: ...
160
189
  def post( # type: ignore [override]
161
190
  self,
@@ -166,7 +195,8 @@ class Client(RequestFactory):
166
195
  secure: bool = ...,
167
196
  *,
168
197
  QUERY_STRING: str = ...,
169
- **extra: str
198
+ headers: Mapping[str, Any] | None = ...,
199
+ **extra: str,
170
200
  ) -> HttpResponse: ...
171
201
  def head( # type: ignore [override]
172
202
  self,
@@ -176,7 +206,8 @@ class Client(RequestFactory):
176
206
  secure: bool = ...,
177
207
  *,
178
208
  QUERY_STRING: str = ...,
179
- **extra: str
209
+ headers: Mapping[str, Any] | None = ...,
210
+ **extra: str,
180
211
  ) -> HttpResponse: ...
181
212
  def trace( # type: ignore [override]
182
213
  self,
@@ -186,7 +217,8 @@ class Client(RequestFactory):
186
217
  secure: bool = ...,
187
218
  *,
188
219
  QUERY_STRING: str = ...,
189
- **extra: str
220
+ headers: Mapping[str, Any] | None = ...,
221
+ **extra: str,
190
222
  ) -> HttpResponse: ...
191
223
  def options( # type: ignore [override]
192
224
  self,
@@ -197,7 +229,8 @@ class Client(RequestFactory):
197
229
  secure: bool = ...,
198
230
  *,
199
231
  QUERY_STRING: str = ...,
200
- **extra: str
232
+ headers: Mapping[str, Any] | None = ...,
233
+ **extra: str,
201
234
  ) -> HttpResponse: ...
202
235
  def put( # type: ignore [override]
203
236
  self,
@@ -208,7 +241,8 @@ class Client(RequestFactory):
208
241
  secure: bool = ...,
209
242
  *,
210
243
  QUERY_STRING: str = ...,
211
- **extra: str
244
+ headers: Mapping[str, Any] | None = ...,
245
+ **extra: str,
212
246
  ) -> HttpResponse: ...
213
247
  def patch( # type: ignore [override]
214
248
  self,
@@ -219,7 +253,8 @@ class Client(RequestFactory):
219
253
  secure: bool = ...,
220
254
  *,
221
255
  QUERY_STRING: str = ...,
222
- **extra: str
256
+ headers: Mapping[str, Any] | None = ...,
257
+ **extra: str,
223
258
  ) -> HttpResponse: ...
224
259
  def delete( # type: ignore [override]
225
260
  self,
@@ -230,7 +265,128 @@ class Client(RequestFactory):
230
265
  secure: bool = ...,
231
266
  *,
232
267
  QUERY_STRING: str = ...,
233
- **extra: str
268
+ headers: Mapping[str, Any] | None = ...,
269
+ **extra: str,
270
+ ) -> HttpResponse: ...
271
+ def store_exc_info(self, **kwargs: Any) -> None: ...
272
+ @property
273
+ def session(self) -> SessionBase: ...
274
+ def login(self, **credentials: Any) -> bool: ...
275
+ def force_login(
276
+ self, user: AbstractBaseUser, backend: str | None = ...
277
+ ) -> None: ...
278
+ def logout(self) -> None: ...
279
+
280
+ class AsyncRequestFactory(RequestFactory): ...
281
+
282
+ class AsyncClient(AsyncRequestFactory):
283
+ handler: AsyncClientHandler
284
+ raise_request_exception: bool
285
+ exc_info: tuple[type[BaseException], BaseException, TracebackType] | None
286
+ headers: dict[str, Any]
287
+ def __init__(
288
+ self,
289
+ enforce_csrf_checks: bool = ...,
290
+ raise_request_exception: bool = ...,
291
+ *,
292
+ json_encoder: type[JSONEncoder] = ...,
293
+ headers: Mapping[str, Any] | None = ...,
294
+ **defaults: Any,
295
+ ) -> None: ...
296
+ # Silence type warnings, since this class overrides arguments and return types in an unsafe manner.
297
+ async def request(self, **request: Any) -> HttpResponse: ... # type: ignore [override]
298
+ async def get( # type: ignore [override]
299
+ self,
300
+ path: str,
301
+ data: _RequestData = ...,
302
+ follow: bool = ...,
303
+ secure: bool = ...,
304
+ *,
305
+ QUERY_STRING: str = ...,
306
+ headers: Mapping[str, Any] | None = ...,
307
+ **extra: str,
308
+ ) -> HttpResponse: ...
309
+ async def post( # type: ignore [override]
310
+ self,
311
+ path: str,
312
+ data: _RequestData = ...,
313
+ content_type: str = ...,
314
+ follow: bool = ...,
315
+ secure: bool = ...,
316
+ *,
317
+ QUERY_STRING: str = ...,
318
+ headers: Mapping[str, Any] | None = ...,
319
+ **extra: str,
320
+ ) -> HttpResponse: ...
321
+ async def head( # type: ignore [override]
322
+ self,
323
+ path: str,
324
+ data: _RequestData = ...,
325
+ follow: bool = ...,
326
+ secure: bool = ...,
327
+ *,
328
+ QUERY_STRING: str = ...,
329
+ headers: Mapping[str, Any] | None = ...,
330
+ **extra: str,
331
+ ) -> HttpResponse: ...
332
+ async def trace( # type: ignore [override]
333
+ self,
334
+ path: str,
335
+ data: _RequestData = ...,
336
+ follow: bool = ...,
337
+ secure: bool = ...,
338
+ *,
339
+ QUERY_STRING: str = ...,
340
+ headers: Mapping[str, Any] | None = ...,
341
+ **extra: str,
342
+ ) -> HttpResponse: ...
343
+ async def options( # type: ignore [override]
344
+ self,
345
+ path: str,
346
+ data: _RequestData = ...,
347
+ content_type: str = ...,
348
+ follow: bool = ...,
349
+ secure: bool = ...,
350
+ *,
351
+ QUERY_STRING: str = ...,
352
+ headers: Mapping[str, Any] | None = ...,
353
+ **extra: str,
354
+ ) -> HttpResponse: ...
355
+ async def put( # type: ignore [override]
356
+ self,
357
+ path: str,
358
+ data: _RequestData = ...,
359
+ content_type: str = ...,
360
+ follow: bool = ...,
361
+ secure: bool = ...,
362
+ *,
363
+ QUERY_STRING: str = ...,
364
+ headers: Mapping[str, Any] | None = ...,
365
+ **extra: str,
366
+ ) -> HttpResponse: ...
367
+ async def patch( # type: ignore [override]
368
+ self,
369
+ path: str,
370
+ data: _RequestData = ...,
371
+ content_type: str = ...,
372
+ follow: bool = ...,
373
+ secure: bool = ...,
374
+ *,
375
+ QUERY_STRING: str = ...,
376
+ headers: Mapping[str, Any] | None = ...,
377
+ **extra: str,
378
+ ) -> HttpResponse: ...
379
+ async def delete( # type: ignore [override]
380
+ self,
381
+ path: str,
382
+ data: _RequestData = ...,
383
+ content_type: str = ...,
384
+ follow: bool = ...,
385
+ secure: bool = ...,
386
+ *,
387
+ QUERY_STRING: str = ...,
388
+ headers: Mapping[str, Any] | None = ...,
389
+ **extra: str,
234
390
  ) -> HttpResponse: ...
235
391
  def store_exc_info(self, **kwargs: Any) -> None: ...
236
392
  @property
@@ -9,7 +9,7 @@ from django.core.servers.basehttp import ThreadedWSGIServer, WSGIRequestHandler
9
9
  from django.db import connections as connections # noqa: F401
10
10
  from django.db.backends.sqlite3.base import DatabaseWrapper
11
11
  from django.db.models import Model
12
- from django.db.models.query import _BaseQuerySet, ValuesQuerySet
12
+ from django.db.models.query import ValuesQuerySet, _BaseQuerySet
13
13
  from django.forms.fields import EmailField
14
14
  from django.http.response import HttpResponse, HttpResponseBase
15
15
  from django.template.base import Template
@@ -27,7 +27,7 @@ class _AssertTemplateUsedContext:
27
27
  template_name: str = ...
28
28
  rendered_templates: list[Template] = ...
29
29
  rendered_template_names: list[str] = ...
30
- context: ContextList = ...
30
+ context: ContextList[Any] = ...
31
31
  def __init__(self, test_case: Any, template_name: Any) -> None: ...
32
32
  def on_template_render(
33
33
  self, sender: Any, signal: Any, template: Any, context: Any, **kwargs: Any
@@ -148,13 +148,13 @@ class SimpleTestCase(unittest.TestCase):
148
148
  ) -> None: ...
149
149
  def assertJSONEqual(
150
150
  self,
151
- raw: str,
151
+ raw: str | bytes | bytearray,
152
152
  expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None,
153
153
  msg: str | None = ...,
154
154
  ) -> None: ...
155
155
  def assertJSONNotEqual(
156
156
  self,
157
- raw: str,
157
+ raw: str | bytes | bytearray,
158
158
  expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None,
159
159
  msg: str | None = ...,
160
160
  ) -> None: ...
@@ -1,21 +1,24 @@
1
1
  import decimal
2
2
  from collections.abc import Callable, Iterable, Iterator, Mapping
3
- from contextlib import AbstractContextManager, contextmanager
3
+ from contextlib import AbstractContextManager
4
4
  from decimal import Decimal
5
- from io import StringIO
6
- from typing import Any, TypeVar
5
+ from types import TracebackType
6
+ from typing import Any, TypeVar, overload
7
+ from typing_extensions import Self
7
8
 
8
9
  from django.apps.registry import Apps
9
10
  from django.conf import LazySettings, Settings
10
11
  from django.core.checks.registry import CheckRegistry
11
- from django.db.models.lookups import Lookup, Transform
12
- from django.db.models.query_utils import RegisterLookupMixin
12
+ from django.db import DefaultConnectionProxy
13
13
  from django.test.runner import DiscoverRunner
14
14
  from django.test.testcases import SimpleTestCase
15
15
 
16
16
  _TestClass = type[SimpleTestCase]
17
17
  _DecoratedTest = Callable[..., Any] | _TestClass
18
18
  _C = TypeVar("_C", bound=Callable[..., Any])
19
+ _T = TypeVar("_T")
20
+ _U = TypeVar("_U")
21
+ _TestClassGeneric = TypeVar("_TestClassGeneric", bound=_TestClass)
19
22
 
20
23
  TZ_SUPPORT: bool = ...
21
24
 
@@ -24,14 +27,25 @@ class Approximate:
24
27
  places: int = ...
25
28
  def __init__(self, val: Decimal | float, places: int = ...) -> None: ...
26
29
 
27
- class ContextList(list[Any]):
28
- def get(self, key: str, default: str | None = ...) -> str: ...
30
+ class ContextList(list[Mapping[str, _T]]):
31
+ def get(self, key: str, default: _U | None = ...) -> _T | _U | None: ...
29
32
  def keys(self) -> set[str]: ...
30
33
 
31
34
  class _TestState: ...
32
35
 
33
36
  def setup_test_environment(debug: bool | None = ...) -> None: ...
34
37
  def teardown_test_environment() -> None: ...
38
+ def setup_databases(
39
+ verbosity: int,
40
+ interactive: bool,
41
+ *,
42
+ time_keeper: Any | None = ...,
43
+ keepdb: bool = ...,
44
+ debug_sql: bool = ...,
45
+ parallel: int = ...,
46
+ aliases: Iterable[str] | None = ...,
47
+ **kwargs: Any
48
+ ) -> list[tuple[DefaultConnectionProxy, str, bool]]: ...
35
49
  def get_runner(
36
50
  settings: LazySettings, test_runner_class: str | None = ...
37
51
  ) -> type[DiscoverRunner]: ...
@@ -42,39 +56,47 @@ class TestContextDecorator:
42
56
  def __init__(
43
57
  self, attr_name: str | None = ..., kwarg_name: str | None = ...
44
58
  ) -> None: ...
45
- def enable(self) -> Any: ...
59
+ def enable(self) -> Any | None: ...
46
60
  def disable(self) -> None: ...
47
- def __enter__(self) -> Apps | None: ...
48
- def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
49
- def decorate_class(self, cls: _TestClass) -> _TestClass: ...
61
+ def __enter__(self) -> Any | None: ...
62
+ def __exit__(
63
+ self,
64
+ exc_type: type[Exception] | None,
65
+ exc_value: Exception | None,
66
+ traceback: TracebackType | None,
67
+ ) -> None: ...
68
+ def decorate_class(self, cls: _TestClassGeneric) -> _TestClassGeneric: ...
50
69
  def decorate_callable(self, func: _C) -> _C: ...
51
- def __call__(self, decorated: _DecoratedTest) -> Any: ...
70
+ @overload
71
+ def __call__(self, decorated: _TestClassGeneric) -> _TestClassGeneric: ...
72
+ @overload
73
+ def __call__(self, decorated: _C) -> _C: ...
52
74
 
53
75
  class override_settings(TestContextDecorator):
76
+ enable_exception: bool | None = ...
77
+ wrapped: Settings = ...
54
78
  options: dict[str, Any] = ...
55
79
  def __init__(self, **kwargs: Any) -> None: ...
56
- wrapped: Settings = ...
57
80
  def save_options(self, test_func: _DecoratedTest) -> None: ...
58
- def decorate_class(self, cls: type) -> type: ...
59
81
 
60
82
  class modify_settings(override_settings):
61
83
  wrapped: Settings
62
84
  operations: list[tuple[str, dict[str, list[str] | str]]] = ...
85
+ options: dict[str, list[tuple[str, str] | str]] = ...
63
86
  def __init__(self, *args: Any, **kwargs: Any) -> None: ...
64
87
  def save_options(self, test_func: _DecoratedTest) -> None: ...
65
- options: dict[str, list[tuple[str, str] | str]] = ...
66
88
 
67
89
  class override_system_checks(TestContextDecorator):
68
90
  registry: CheckRegistry = ...
69
91
  new_checks: list[Callable[..., Any]] = ...
70
92
  deployment_checks: list[Callable[..., Any]] | None = ...
93
+ old_checks: set[Callable[..., Any]] = ...
94
+ old_deployment_checks: set[Callable[..., Any]] = ...
71
95
  def __init__(
72
96
  self,
73
97
  new_checks: list[Callable[..., Any]],
74
98
  deployment_checks: list[Callable[..., Any]] | None = ...,
75
99
  ) -> None: ...
76
- old_checks: set[Callable[..., Any]] = ...
77
- old_deployment_checks: set[Callable[..., Any]] = ...
78
100
 
79
101
  class CaptureQueriesContext:
80
102
  connection: Any = ...
@@ -87,7 +109,7 @@ class CaptureQueriesContext:
87
109
  def __len__(self) -> int: ...
88
110
  @property
89
111
  def captured_queries(self) -> list[dict[str, str]]: ...
90
- def __enter__(self) -> CaptureQueriesContext: ...
112
+ def __enter__(self) -> Self: ...
91
113
  def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
92
114
 
93
115
  class ignore_warnings(TestContextDecorator):
@@ -117,40 +139,4 @@ class isolate_apps(TestContextDecorator):
117
139
  def __init__(self, *installed_apps: Any, **kwargs: Any) -> None: ...
118
140
  old_apps: Apps = ...
119
141
 
120
- @contextmanager
121
- def extend_sys_path(*paths: str) -> Iterator[None]: ...
122
- @contextmanager
123
- def captured_output(stream_name: Any) -> Iterator[StringIO]: ...
124
- @contextmanager
125
- def captured_stdin() -> Iterator[StringIO]: ...
126
- @contextmanager
127
- def captured_stdout() -> Iterator[StringIO]: ...
128
- @contextmanager
129
- def captured_stderr() -> Iterator[StringIO]: ...
130
- @contextmanager
131
- def freeze_time(t: float) -> Iterator[None]: ...
132
- def tag(*tags: str) -> Any: ...
133
-
134
- _Signature = str
135
- _TestDatabase = tuple[str, list[str]]
136
-
137
- def dependency_ordered(
138
- test_databases: Iterable[tuple[_Signature, _TestDatabase]],
139
- dependencies: Mapping[str, list[str]],
140
- ) -> list[tuple[_Signature, _TestDatabase]]: ...
141
- def get_unique_databases_and_mirrors() -> (
142
- tuple[dict[_Signature, _TestDatabase], dict[str, Any]]
143
- ): ...
144
- def teardown_databases(
145
- old_config: Iterable[tuple[Any, str, bool]],
146
- verbosity: int,
147
- parallel: int = ...,
148
- keepdb: bool = ...,
149
- ) -> None: ...
150
- def require_jinja2(test_func: _C) -> _C: ...
151
- @contextmanager
152
- def register_lookup(
153
- field: type[RegisterLookupMixin],
154
- *lookups: type[Lookup[Any] | Transform],
155
- lookup_name: str | None = ...
156
- ) -> Iterator[None]: ...
142
+ def tag(*tags: str) -> Callable[[_T], _T]: ...
@@ -1,8 +1,21 @@
1
- from collections.abc import Callable, Sequence
2
- from typing import Any
1
+ from collections.abc import Callable, Mapping, Sequence
2
+ from typing import Any, TypeAlias
3
3
 
4
+ from django.http.request import QueryDict
4
5
  from django.urls.resolvers import ResolverMatch
5
6
 
7
+ # The values are passed through `str()` (unless they are bytes), so anything is valid.
8
+ _QueryType: TypeAlias = (
9
+ Mapping[str, object]
10
+ | Mapping[bytes, object]
11
+ | Mapping[str | bytes, object]
12
+ | Mapping[str, Sequence[object]]
13
+ | Mapping[bytes, Sequence[object]]
14
+ | Mapping[str | bytes, Sequence[object]]
15
+ | Sequence[tuple[str | bytes, object]]
16
+ | Sequence[tuple[str | bytes, Sequence[object]]]
17
+ )
18
+
6
19
  def resolve(path: str, urlconf: str | None = ...) -> ResolverMatch: ...
7
20
  def reverse(
8
21
  viewname: Callable[..., Any] | str | None,
@@ -10,6 +23,9 @@ def reverse(
10
23
  args: Sequence[Any] | None = ...,
11
24
  kwargs: dict[str, Any] | None = ...,
12
25
  current_app: str | None = ...,
26
+ *,
27
+ query: QueryDict | _QueryType | None = ...,
28
+ fragment: str | None = ...,
13
29
  ) -> str: ...
14
30
 
15
31
  reverse_lazy: Any
@@ -32,6 +32,13 @@ def path(
32
32
  kwargs: dict[str, Any] = ...,
33
33
  name: str = ...,
34
34
  ) -> URLResolver: ...
35
+ @overload
36
+ def path(
37
+ route: str,
38
+ view: tuple[list[URLResolver | URLPattern], str, str],
39
+ kwargs: dict[str, Any] = ...,
40
+ name: str = ...,
41
+ ) -> URLResolver: ...
35
42
 
36
43
  # re_path()
37
44
  @overload
@@ -1,7 +1,7 @@
1
1
  from typing import Any
2
2
 
3
3
  from django.core.cache.backends.base import BaseCache
4
- from django.core.handlers.wsgi import WSGIRequest
4
+ from django.http.request import HttpRequest
5
5
  from django.http.response import HttpResponse, HttpResponseBase
6
6
 
7
7
  cc_delim_re: Any
@@ -10,7 +10,7 @@ def patch_cache_control(response: HttpResponseBase, **kwargs: Any) -> None: ...
10
10
  def get_max_age(response: HttpResponse) -> int | None: ...
11
11
  def set_response_etag(response: HttpResponseBase) -> HttpResponseBase: ...
12
12
  def get_conditional_response(
13
- request: WSGIRequest,
13
+ request: HttpRequest,
14
14
  etag: str | None = ...,
15
15
  last_modified: int | None = ...,
16
16
  response: HttpResponse | None = ...,
@@ -22,13 +22,13 @@ def add_never_cache_headers(response: HttpResponseBase) -> None: ...
22
22
  def patch_vary_headers(response: HttpResponseBase, newheaders: tuple[str]) -> None: ...
23
23
  def has_vary_header(response: HttpResponse, header_query: str) -> bool: ...
24
24
  def get_cache_key(
25
- request: WSGIRequest,
25
+ request: HttpRequest,
26
26
  key_prefix: str | None = ...,
27
27
  method: str = ...,
28
28
  cache: BaseCache | None = ...,
29
29
  ) -> str | None: ...
30
30
  def learn_cache_key(
31
- request: WSGIRequest,
31
+ request: HttpRequest,
32
32
  response: HttpResponse,
33
33
  cache_timeout: float | None = ...,
34
34
  key_prefix: str | None = ...,
@@ -6,8 +6,8 @@ from collections.abc import (
6
6
  MutableMapping,
7
7
  MutableSet,
8
8
  )
9
- from typing import Any, TypeVar, overload
10
- from typing_extensions import Literal, Self
9
+ from typing import Any, Literal, TypeVar, overload
10
+ from typing_extensions import Self
11
11
 
12
12
  _K = TypeVar("_K")
13
13
  _V = TypeVar("_V")
@@ -76,9 +76,9 @@ class DictWrapper(dict[str, _V]):
76
76
  self, data: Iterable[tuple[str, _V]], func: Callable[[_V], _V], prefix: str
77
77
  ) -> None: ...
78
78
 
79
- class CaseInsensitiveMapping(Mapping[_K, _V]):
79
+ class CaseInsensitiveMapping(Mapping[str, _V]):
80
80
  def __init__(self, data: Any) -> None: ...
81
- def __getitem__(self, key: _K) -> Any: ...
81
+ def __getitem__(self, key: str) -> Any: ...
82
82
  def __len__(self) -> int: ...
83
- def __iter__(self) -> Iterator[_K]: ...
83
+ def __iter__(self) -> Iterator[str]: ...
84
84
  def copy(self) -> Self: ...
@@ -1,3 +1,11 @@
1
- from typing import Any
1
+ from collections.abc import Callable
2
+ from typing import Any, TypeVar, overload
2
3
 
3
- def deconstructible(*args: Any, path: Any | None = ...) -> Any: ...
4
+ T = TypeVar("T")
5
+
6
+ @overload
7
+ def deconstructible(klass: type[T]) -> type[T]: ...
8
+ @overload
9
+ def deconstructible(
10
+ *args: Any, path: str | None = ...
11
+ ) -> Callable[[type[T]], type[T]]: ...
@@ -36,7 +36,7 @@ class RequireDebugTrue(logging.Filter):
36
36
  def filter(self, record: str | LogRecord) -> bool: ...
37
37
 
38
38
  class ServerFormatter(logging.Formatter):
39
- datefmt: None
39
+ datefmt: None # pyright: ignore[reportIncompatibleVariableOverride]
40
40
  style: Style = ...
41
41
  def __init__(self, *args: Any, **kwargs: Any) -> None: ...
42
42
  def uses_server_time(self) -> bool: ...
@@ -43,7 +43,7 @@ def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
43
43
  def get_method_self(meth: types.MethodType) -> object | None: ...
44
44
  def get_function_closure(
45
45
  fun: types.FunctionType,
46
- ) -> tuple[types._Cell, ...] | None: ...
46
+ ) -> tuple[types._Cell, ...] | None: ... # pyright: ignore[reportAttributeAccessIssue]
47
47
  def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
48
48
  def get_function_defaults(fun: types.FunctionType) -> tuple[Any, ...] | None: ...
49
49
  def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ...