django-types 0.21.0__py3-none-any.whl → 0.23.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 (114) hide show
  1. django-stubs/apps/config.pyi +3 -2
  2. django-stubs/conf/global_settings.pyi +9 -9
  3. django-stubs/conf/urls/__init__.pyi +2 -2
  4. django-stubs/contrib/admin/checks.pyi +2 -2
  5. django-stubs/contrib/admin/models.pyi +4 -4
  6. django-stubs/contrib/admin/options.pyi +21 -13
  7. django-stubs/contrib/admin/utils.pyi +1 -2
  8. django-stubs/contrib/admin/views/main.pyi +1 -1
  9. django-stubs/contrib/auth/backends.pyi +2 -2
  10. django-stubs/contrib/auth/decorators.pyi +1 -1
  11. django-stubs/contrib/auth/management/commands/createsuperuser.pyi +1 -1
  12. django-stubs/contrib/auth/models.pyi +3 -3
  13. django-stubs/contrib/contenttypes/fields.pyi +1 -1
  14. django-stubs/contrib/gis/db/models/__init__.pyi +2 -2
  15. django-stubs/contrib/gis/gdal/srs.pyi +4 -4
  16. django-stubs/contrib/gis/geos/geometry.pyi +1 -1
  17. django-stubs/contrib/gis/geos/io.pyi +1 -1
  18. django-stubs/contrib/postgres/fields/array.pyi +1 -1
  19. django-stubs/contrib/postgres/fields/citext.pyi +9 -9
  20. django-stubs/contrib/postgres/fields/hstore.pyi +7 -7
  21. django-stubs/contrib/postgres/fields/ranges.pyi +6 -6
  22. django-stubs/contrib/postgres/search.pyi +3 -3
  23. django-stubs/contrib/sessions/base_session.pyi +1 -1
  24. django-stubs/contrib/sessions/models.pyi +1 -1
  25. django-stubs/contrib/sites/models.pyi +1 -1
  26. django-stubs/core/checks/registry.pyi +2 -2
  27. django-stubs/core/exceptions.pyi +2 -2
  28. django-stubs/core/files/base.pyi +1 -1
  29. django-stubs/core/handlers/wsgi.pyi +3 -3
  30. django-stubs/core/mail/__init__.pyi +2 -1
  31. django-stubs/core/mail/backends/base.pyi +1 -1
  32. django-stubs/core/mail/message.pyi +7 -7
  33. django-stubs/core/management/__init__.pyi +10 -8
  34. django-stubs/core/management/base.pyi +49 -33
  35. django-stubs/core/management/commands/compilemessages.pyi +2 -2
  36. django-stubs/core/servers/basehttp.pyi +1 -1
  37. django-stubs/core/validators.pyi +4 -4
  38. django-stubs/db/backends/base/operations.pyi +2 -2
  39. django-stubs/db/backends/base/schema.pyi +7 -1
  40. django-stubs/db/backends/utils.pyi +3 -3
  41. django-stubs/db/migrations/__init__.pyi +1 -1
  42. django-stubs/db/migrations/migration.pyi +1 -2
  43. django-stubs/db/migrations/operations/base.pyi +41 -16
  44. django-stubs/db/migrations/topological_sort.pyi +1 -1
  45. django-stubs/db/models/__init__.pyi +3 -0
  46. django-stubs/db/models/aggregates.pyi +5 -1
  47. django-stubs/db/models/base.pyi +1 -1
  48. django-stubs/db/models/constants.pyi +8 -1
  49. django-stubs/db/models/constraints.pyi +56 -17
  50. django-stubs/db/models/enums.pyi +3 -1
  51. django-stubs/db/models/expressions.pyi +7 -7
  52. django-stubs/db/models/fields/__init__.pyi +28 -25
  53. django-stubs/db/models/fields/composite.pyi +73 -0
  54. django-stubs/db/models/fields/files.pyi +3 -1
  55. django-stubs/db/models/fields/generated.pyi +84 -0
  56. django-stubs/db/models/fields/json.pyi +3 -1
  57. django-stubs/db/models/fields/related.pyi +26 -21
  58. django-stubs/db/models/indexes.pyi +1 -1
  59. django-stubs/db/models/lookups.pyi +1 -1
  60. django-stubs/db/models/manager.pyi +1 -1
  61. django-stubs/db/models/options.pyi +1 -0
  62. django-stubs/db/models/query.pyi +6 -6
  63. django-stubs/db/utils.pyi +41 -17
  64. django-stubs/dispatch/dispatcher.pyi +33 -26
  65. django-stubs/forms/fields.pyi +4 -4
  66. django-stubs/forms/models.pyi +4 -4
  67. django-stubs/forms/renderers.pyi +1 -1
  68. django-stubs/forms/widgets.pyi +2 -2
  69. django-stubs/http/request.pyi +4 -3
  70. django-stubs/http/response.pyi +9 -3
  71. django-stubs/shortcuts.pyi +17 -32
  72. django-stubs/template/backends/django.pyi +1 -1
  73. django-stubs/template/backends/dummy.pyi +1 -1
  74. django-stubs/template/backends/jinja2.pyi +1 -1
  75. django-stubs/template/base.pyi +5 -5
  76. django-stubs/template/context.pyi +9 -3
  77. django-stubs/template/defaultfilters.pyi +1 -1
  78. django-stubs/template/engine.pyi +2 -2
  79. django-stubs/template/library.pyi +1 -1
  80. django-stubs/template/loader.pyi +2 -4
  81. django-stubs/template/response.pyi +2 -2
  82. django-stubs/template/smartif.pyi +2 -2
  83. django-stubs/test/client.pyi +3 -3
  84. django-stubs/test/html.pyi +2 -2
  85. django-stubs/test/signals.pyi +1 -1
  86. django-stubs/test/testcases.pyi +10 -4
  87. django-stubs/test/utils.pyi +12 -7
  88. django-stubs/urls/conf.pyi +2 -2
  89. django-stubs/utils/archive.pyi +7 -1
  90. django-stubs/utils/connection.pyi +38 -0
  91. django-stubs/utils/datastructures.pyi +1 -0
  92. django-stubs/utils/dateformat.pyi +3 -3
  93. django-stubs/utils/deprecation.pyi +2 -2
  94. django-stubs/utils/functional.pyi +64 -31
  95. django-stubs/utils/safestring.pyi +1 -0
  96. django-stubs/utils/six.pyi +4 -5
  97. django-stubs/utils/timezone.pyi +7 -7
  98. django-stubs/utils/topological_sort.pyi +1 -1
  99. django-stubs/utils/translation/__init__.pyi +15 -6
  100. django-stubs/utils/tree.pyi +2 -2
  101. django-stubs/utils/xmlutils.pyi +2 -1
  102. django-stubs/views/__init__.pyi +2 -0
  103. django-stubs/views/csrf.pyi +4 -4
  104. django-stubs/views/debug.pyi +49 -50
  105. django-stubs/views/decorators/cache.pyi +1 -1
  106. django-stubs/views/decorators/debug.pyi +3 -1
  107. django-stubs/views/defaults.pyi +3 -6
  108. django-stubs/views/generic/dates.pyi +4 -2
  109. django-stubs/views/i18n.pyi +7 -16
  110. django-stubs/views/static.pyi +6 -7
  111. {django_types-0.21.0.dist-info → django_types-0.23.0.dist-info}/METADATA +8 -15
  112. {django_types-0.21.0.dist-info → django_types-0.23.0.dist-info}/RECORD +187 -184
  113. {django_types-0.21.0.dist-info → django_types-0.23.0.dist-info}/WHEEL +1 -1
  114. {django_types-0.21.0.dist-info → django_types-0.23.0.dist-info/licenses}/LICENSE.txt +0 -0
django-stubs/db/utils.pyi CHANGED
@@ -1,7 +1,16 @@
1
- from collections.abc import Iterable
2
- from typing import Any
1
+ from collections.abc import Callable, Iterable
2
+ from types import TracebackType
3
+ from typing import Any, ParamSpec, TypeVar
4
+ from typing import Any as Incomplete
3
5
 
4
- from django.db import DefaultConnectionProxy
6
+ from django.apps import AppConfig
7
+ from django.db.backends.base.base import BaseDatabaseWrapper
8
+ from django.db.models import Model
9
+ from django.utils.connection import BaseConnectionHandler
10
+ from django.utils.connection import ConnectionDoesNotExist as ConnectionDoesNotExist
11
+
12
+ _P = ParamSpec("_P")
13
+ _R = TypeVar("_R")
5
14
 
6
15
  DEFAULT_DB_ALIAS: str
7
16
  DJANGO_VERSION_PICKLE_KEY: str
@@ -16,23 +25,38 @@ class InternalError(DatabaseError): ...
16
25
  class ProgrammingError(DatabaseError): ...
17
26
  class NotSupportedError(DatabaseError): ...
18
27
 
19
- def load_backend(backend_name: str) -> Any: ...
28
+ class DatabaseErrorWrapper:
29
+ wrapper: Incomplete
30
+ def __init__(self, wrapper: Incomplete) -> None: ...
31
+ def __enter__(self) -> None: ...
32
+ def __exit__(
33
+ self,
34
+ exc_type: type[BaseException] | None,
35
+ exc_value: BaseException | None,
36
+ traceback: TracebackType | None,
37
+ ) -> None: ...
38
+ def __call__(self, func: Callable[_P, _R]) -> Callable[_P, _R]: ...
20
39
 
21
- class ConnectionDoesNotExist(Exception): ...
40
+ def load_backend(backend_name: str) -> Any: ...
22
41
 
23
- class ConnectionHandler:
24
- databases: dict[str, dict[str, Any | None]]
25
- def __init__(self, databases: dict[str, dict[str, Any | None]] = ...) -> None: ...
26
- def ensure_defaults(self, alias: str) -> None: ...
27
- def prepare_test_settings(self, alias: str) -> None: ...
28
- def __getitem__(self, alias: str) -> DefaultConnectionProxy: ...
29
- def __setitem__(self, key: Any, value: Any) -> None: ...
30
- def __delitem__(self, key: Any) -> None: ...
31
- def __iter__(self) -> Any: ...
32
- def all(self) -> list[Any]: ...
33
- def close_all(self) -> None: ...
42
+ class ConnectionHandler(BaseConnectionHandler):
43
+ settings_name: str # pyright: ignore[reportIncompatibleVariableOverride]
44
+ def configure_settings(
45
+ self, databases: dict[str, dict[str, Any]] | None
46
+ ) -> dict[str, dict[str, Any]]: ...
47
+ @property
48
+ def databases(self) -> dict[str, dict[str, Any]]: ...
49
+ def create_connection(self, alias: str) -> BaseDatabaseWrapper: ...
34
50
 
35
51
  class ConnectionRouter:
36
- def __init__(self, routers: Iterable[Any] | None = ...) -> None: ...
52
+ def __init__(self, routers: Iterable[Any] | None = None) -> None: ...
37
53
  @property
38
54
  def routers(self) -> list[Any]: ...
55
+ def db_for_read(self, model: type[Model], **hints: Any) -> str: ...
56
+ def db_for_write(self, model: type[Model], **hints: Any) -> str: ...
57
+ def allow_relation(self, obj1: Model, obj2: Model, **hints: Any) -> bool: ...
58
+ def allow_migrate(self, db: str, app_label: str, **hints: Any) -> bool: ...
59
+ def allow_migrate_model(self, db: str, model: type[Model]) -> bool: ...
60
+ def get_migratable_models(
61
+ self, app_config: AppConfig, db: str, include_auto_created: bool = False
62
+ ) -> list[type[Model]]: ...
@@ -1,37 +1,44 @@
1
- from collections.abc import Callable
2
- from typing import Any
1
+ import threading
2
+ from collections.abc import Callable, Hashable, MutableMapping
3
+ from logging import Logger
4
+ from typing import Any, TypeVar
3
5
 
4
- NONE_ID: Any
6
+ NONE_ID: int
5
7
  NO_RECEIVERS: Any
6
8
 
9
+ logger: Logger
10
+
7
11
  class Signal:
8
- receivers: Any = ...
9
- providing_args: Any = ...
10
- lock: Any = ...
11
- use_caching: Any = ...
12
- sender_receivers_cache: Any = ...
13
- def __init__(
14
- self, providing_args: list[str] = ..., use_caching: bool = ...
15
- ) -> None: ...
12
+ receivers: list[Any]
13
+ lock: threading.Lock
14
+ use_caching: bool
15
+ sender_receivers_cache: MutableMapping[Any, Any]
16
+
17
+ def __init__(self, use_caching: bool = False) -> None: ...
16
18
  def connect(
17
19
  self,
18
20
  receiver: Callable[..., Any],
19
- sender: object | None = ...,
20
- weak: bool = ...,
21
- dispatch_uid: str | None = ...,
21
+ sender: object | None = None,
22
+ weak: bool = True,
23
+ dispatch_uid: Hashable | None = None,
22
24
  ) -> None: ...
23
25
  def disconnect(
24
- self,
25
- receiver: Callable[..., Any] | None = ...,
26
- sender: object | None = ...,
27
- dispatch_uid: str | None = ...,
26
+ self, receiver: Callable[..., Any] | None = None, sender: object | None = None, dispatch_uid: str | None = None
28
27
  ) -> bool: ...
29
- def has_listeners(self, sender: Any = ...) -> bool: ...
30
- def send(
31
- self, sender: Any, **named: Any
32
- ) -> list[tuple[Callable[..., Any], str | None]]: ...
33
- def send_robust(
34
- self, sender: Any, **named: Any
35
- ) -> list[tuple[Callable[..., Any], ValueError | str]]: ...
28
+ def has_listeners(self, sender: Any | None = None) -> bool: ...
29
+ def send(self, sender: Any, **named: Any) -> list[tuple[Callable[..., Any], str | None]]: ...
30
+ async def asend(self, sender: Any, **named: Any) -> list[tuple[Callable[..., Any], str | None]]: ...
31
+ def send_robust(self, sender: Any, **named: Any) -> list[tuple[Callable[..., Any], Exception | Any]]: ...
32
+ async def asend_robust(self, sender: Any, **named: Any) -> list[tuple[Callable[..., Any], Exception | Any]]: ...
33
+ def _live_receivers(self, sender: Any) -> tuple[list[Callable[..., Any]], list[Callable[..., Any]]]: ...
34
+
35
+ _F = TypeVar("_F", bound=Callable[..., Any])
36
36
 
37
- def receiver(signal: list[Signal] | Signal, **kwargs: Any) -> Callable[..., Any]: ...
37
+ def receiver(
38
+ signal: list[Signal] | tuple[Signal, ...] | Signal,
39
+ *,
40
+ sender: object | None = ...,
41
+ weak: bool = ...,
42
+ dispatch_uid: Hashable | None = ...,
43
+ **named: Any,
44
+ ) -> Callable[[_F], _F]: ...
@@ -1,16 +1,16 @@
1
1
  from collections.abc import Callable, Iterable, Sequence
2
2
  from datetime import datetime, timedelta
3
3
  from re import Pattern
4
- from typing import Any
4
+ from typing import Any, TypeAlias
5
5
 
6
6
  from django.core.validators import BaseValidator
7
7
  from django.forms.boundfield import BoundField
8
8
  from django.forms.forms import BaseForm
9
9
  from django.forms.widgets import Widget
10
10
 
11
- _Choice = tuple[Any, str]
12
- _ChoiceNamedGroup = tuple[str, Iterable[_Choice]]
13
- _FieldChoices = Iterable[_Choice | _ChoiceNamedGroup]
11
+ _Choice: TypeAlias = tuple[Any, str]
12
+ _ChoiceNamedGroup: TypeAlias = tuple[str, Iterable[_Choice]]
13
+ _FieldChoices: TypeAlias = Iterable[_Choice | _ChoiceNamedGroup]
14
14
 
15
15
  class Field:
16
16
  initial: Any
@@ -7,7 +7,7 @@ from collections.abc import (
7
7
  Sequence,
8
8
  )
9
9
  from datetime import datetime
10
- from typing import Any, ClassVar, Literal, Protocol, TypeVar
10
+ from typing import Any, ClassVar, Literal, Protocol, TypeAlias, TypeVar
11
11
  from unittest.mock import MagicMock
12
12
  from uuid import UUID
13
13
 
@@ -26,9 +26,9 @@ from django.forms.widgets import Input, Widget
26
26
 
27
27
  ALL_FIELDS: str
28
28
 
29
- _Fields = list[Callable[..., Any] | str] | Sequence[str] | Literal["__all__"]
30
- _Labels = dict[str, str]
31
- _ErrorMessages = dict[str, dict[str, str]]
29
+ _Fields: TypeAlias = list[Callable[..., Any] | str] | Sequence[str] | Literal["__all__"]
30
+ _Labels: TypeAlias = dict[str, str]
31
+ _ErrorMessages: TypeAlias = dict[str, dict[str, str]]
32
32
 
33
33
  _M = TypeVar("_M", bound=Model)
34
34
 
@@ -1,12 +1,12 @@
1
1
  from collections.abc import Mapping
2
2
  from typing import Any
3
- from typing_extensions import override
4
3
 
5
4
  from django.http.request import HttpRequest
6
5
  from django.template.backends.base import BaseEngine, _BaseTemplate
7
6
  from django.template.backends.django import Template as DjangoTemplate
8
7
  from django.template.backends.jinja2 import Template as Jinja2Template
9
8
  from django.utils.safestring import SafeText
9
+ from typing_extensions import override
10
10
 
11
11
  def get_default_renderer() -> BaseRenderer: ...
12
12
 
@@ -1,13 +1,13 @@
1
1
  from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
2
2
  from decimal import Decimal
3
3
  from itertools import chain
4
- from typing import Any
4
+ from typing import Any, TypeAlias
5
5
 
6
6
  from django.core.files.base import File
7
7
  from django.forms.renderers import BaseRenderer
8
8
  from django.utils.safestring import SafeText
9
9
 
10
- _OptAttrs = dict[str, Any]
10
+ _OptAttrs: TypeAlias = dict[str, Any]
11
11
 
12
12
  class MediaOrderConflictWarning(RuntimeWarning): ...
13
13
 
@@ -1,7 +1,6 @@
1
1
  from collections.abc import Iterable, Mapping
2
2
  from re import Pattern
3
- from typing import Any, BinaryIO, TypeVar, overload
4
- from typing_extensions import Self
3
+ from typing import Any, BinaryIO, TypeAlias, TypeVar, overload
5
4
 
6
5
  from django.contrib.auth.models import _AnyUser
7
6
  from django.contrib.sessions.backends.base import SessionBase
@@ -13,6 +12,7 @@ from django.utils.datastructures import (
13
12
  ImmutableList,
14
13
  MultiValueDict,
15
14
  )
15
+ from typing_extensions import Self
16
16
 
17
17
  RAISE_ERROR: object = ...
18
18
  host_validation_re: Pattern[str] = ...
@@ -20,7 +20,7 @@ host_validation_re: Pattern[str] = ...
20
20
  class UnreadablePostError(OSError): ...
21
21
  class RawPostDataException(Exception): ...
22
22
 
23
- UploadHandlerList = (
23
+ UploadHandlerList: TypeAlias = (
24
24
  list[uploadhandler.FileUploadHandler]
25
25
  | ImmutableList[uploadhandler.FileUploadHandler]
26
26
  )
@@ -59,6 +59,7 @@ class HttpRequest:
59
59
  def __init__(self) -> None: ...
60
60
  @property
61
61
  def accepted_types(self) -> list[MediaType]: ...
62
+ def get_preferred_type(self, media_types: list[str]) -> str | None: ...
62
63
  def accepts(self, media_type: str) -> bool: ...
63
64
  def get_host(self) -> str: ...
64
65
  def get_port(self) -> str: ...
@@ -3,7 +3,6 @@ from collections.abc import AsyncIterable, AsyncIterator, Iterable, Iterator
3
3
  from io import BytesIO
4
4
  from json import JSONEncoder
5
5
  from typing import Any, overload
6
- from typing_extensions import Never
7
6
 
8
7
  from django.core.handlers.wsgi import WSGIRequest
9
8
  from django.http.cookie import SimpleCookie
@@ -11,6 +10,7 @@ from django.template import Context, Template
11
10
  from django.test.client import Client
12
11
  from django.urls import ResolverMatch
13
12
  from django.utils.datastructures import CaseInsensitiveMapping
13
+ from typing_extensions import Never
14
14
 
15
15
  class ResponseHeaders(CaseInsensitiveMapping[str]):
16
16
  def pop(self, key: str, default: str | None = ...) -> str: ...
@@ -19,7 +19,7 @@ class ResponseHeaders(CaseInsensitiveMapping[str]):
19
19
  class BadHeaderError(ValueError): ...
20
20
 
21
21
  class HttpResponseBase:
22
- cookies: SimpleCookie # type: ignore [type-arg]
22
+ cookies: SimpleCookie
23
23
  headers: ResponseHeaders
24
24
  status_code: int
25
25
  closed: bool
@@ -82,6 +82,8 @@ class HttpResponse(HttpResponseBase, Iterable[bytes]):
82
82
  def serialize(self) -> bytes: ...
83
83
  @property
84
84
  def content(self) -> bytes: ...
85
+ @property
86
+ def text(self) -> str: ...
85
87
  def __iter__(self) -> Iterator[bytes]: ...
86
88
  def write(self, content: str | bytes) -> None: ...
87
89
  def tell(self) -> int: ...
@@ -111,6 +113,8 @@ class StreamingHttpResponse(HttpResponseBase, Iterable[bytes], AsyncIterable[byt
111
113
  def getvalue(self) -> bytes: ...
112
114
  @property
113
115
  def content(self) -> Never: ...
116
+ @property
117
+ def text(self) -> Never: ...
114
118
  def __iter__(self) -> Iterator[bytes]: ...
115
119
  def __aiter__(self) -> AsyncIterator[bytes]: ...
116
120
 
@@ -125,7 +129,9 @@ class FileResponse(StreamingHttpResponse):
125
129
 
126
130
  class HttpResponseRedirectBase(HttpResponse):
127
131
  allowed_schemes: list[str] = ...
128
- def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ...
132
+ def __init__(
133
+ self, redirect_to: str, preserve_request: bool = ..., *args: Any, **kwargs: Any
134
+ ) -> None: ...
129
135
  @property
130
136
  def url(self) -> str: ...
131
137
 
@@ -1,63 +1,48 @@
1
1
  from collections.abc import Callable, Mapping, Sequence
2
- from typing import Any, Literal, Protocol, TypeVar, overload
2
+ from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
3
3
 
4
4
  from django.db.models import Manager, QuerySet
5
5
  from django.db.models.base import Model
6
6
  from django.http import HttpRequest
7
- from django.http.response import HttpResponse as HttpResponse
8
- from django.http.response import (
9
- HttpResponsePermanentRedirect as HttpResponsePermanentRedirect,
10
- )
11
- from django.http.response import HttpResponseRedirect as HttpResponseRedirect
7
+ from django.http.response import HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect
12
8
 
13
- def render_to_response(
14
- template_name: str | Sequence[str],
15
- context: Mapping[str, Any] | None = ...,
16
- content_type: str | None = ...,
17
- status: int | None = ...,
18
- using: str | None = ...,
19
- ) -> HttpResponse: ...
20
9
  def render(
21
- request: HttpRequest,
10
+ request: HttpRequest | None,
22
11
  template_name: str | Sequence[str],
23
12
  context: Mapping[str, Any] | None = ...,
24
13
  content_type: str | None = ...,
25
14
  status: int | None = ...,
26
15
  using: str | None = ...,
27
16
  ) -> HttpResponse: ...
28
-
29
- class SupportsGetAbsoluteUrl(Protocol): ...
17
+ @type_check_only
18
+ class SupportsGetAbsoluteUrl(Protocol):
19
+ def get_absolute_url(self) -> str: ...
30
20
 
31
21
  @overload
32
22
  def redirect(
33
23
  to: Callable[..., Any] | str | SupportsGetAbsoluteUrl,
34
24
  *args: Any,
35
25
  permanent: Literal[True],
36
- **kwargs: Any
26
+ preserve_request: bool = False,
27
+ **kwargs: Any,
37
28
  ) -> HttpResponsePermanentRedirect: ...
38
29
  @overload
39
30
  def redirect(
40
31
  to: Callable[..., Any] | str | SupportsGetAbsoluteUrl,
41
32
  *args: Any,
42
- permanent: Literal[False],
43
- **kwargs: Any
33
+ permanent: Literal[False] = False,
34
+ preserve_request: bool = False,
35
+ **kwargs: Any,
44
36
  ) -> HttpResponseRedirect: ...
45
37
  @overload
46
38
  def redirect(
47
- to: Callable[..., Any] | str | SupportsGetAbsoluteUrl,
48
- *args: Any,
49
- permanent: bool = ...,
50
- **kwargs: Any
39
+ to: Callable[..., Any] | str | SupportsGetAbsoluteUrl, *args: Any, permanent: bool, **kwargs: Any
51
40
  ) -> HttpResponseRedirect | HttpResponsePermanentRedirect: ...
52
41
 
53
42
  _T = TypeVar("_T", bound=Model)
54
43
 
55
- def get_object_or_404(
56
- klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any
57
- ) -> _T: ...
58
- def get_list_or_404(
59
- klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any
60
- ) -> list[_T]: ...
61
- def resolve_url(
62
- to: Callable[..., Any] | Model | str, *args: Any, **kwargs: Any
63
- ) -> str: ...
44
+ def get_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
45
+ async def aget_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
46
+ def get_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
47
+ async def aget_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
48
+ def resolve_url(to: Callable[..., Any] | Model | str, *args: Any, **kwargs: Any) -> str: ...
@@ -1,12 +1,12 @@
1
1
  from collections.abc import Iterator, Mapping
2
2
  from typing import Any, NoReturn
3
- from typing_extensions import override
4
3
 
5
4
  from django.http.request import HttpRequest
6
5
  from django.template import base
7
6
  from django.template.engine import Engine
8
7
  from django.template.exceptions import TemplateDoesNotExist
9
8
  from django.utils.safestring import SafeText
9
+ from typing_extensions import override
10
10
 
11
11
  from .base import BaseEngine
12
12
 
@@ -1,9 +1,9 @@
1
1
  import string
2
2
  from collections.abc import Mapping
3
3
  from typing import Any
4
- from typing_extensions import override
5
4
 
6
5
  from django.http.request import HttpRequest
6
+ from typing_extensions import override
7
7
 
8
8
  from .base import BaseEngine
9
9
 
@@ -1,11 +1,11 @@
1
1
  from collections.abc import Callable, Mapping
2
2
  from typing import Any
3
- from typing_extensions import override
4
3
 
5
4
  from django.http.request import HttpRequest
6
5
  from django.template import base
7
6
  from django.template.exceptions import TemplateSyntaxError
8
7
  from django.utils.safestring import SafeText
8
+ from typing_extensions import override
9
9
 
10
10
  from .base import BaseEngine
11
11
 
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Callable, Iterator, Mapping, Sequence
2
2
  from enum import Enum
3
- from typing import Any
3
+ from typing import Any, cast
4
4
 
5
5
  from django.http.request import HttpRequest
6
6
  from django.template.context import Context as Context
@@ -26,10 +26,10 @@ tag_re: Any
26
26
  logger: Any
27
27
 
28
28
  class TokenType(Enum):
29
- TEXT: int
30
- VAR: int
31
- BLOCK: int
32
- COMMENT: int
29
+ TEXT = cast(int, ...)
30
+ VAR = cast(int, ...)
31
+ BLOCK = cast(int, ...)
32
+ COMMENT = cast(int, ...)
33
33
 
34
34
  class VariableDoesNotExist(Exception):
35
35
  msg: str = ...
@@ -1,12 +1,13 @@
1
1
  from collections.abc import Callable, Iterable, Iterator
2
- from typing import Any
2
+ from types import TracebackType
3
+ from typing import Any, TypeAlias
3
4
 
4
5
  from django.http.request import HttpRequest
5
6
  from django.template.base import Node, Origin, Template
6
7
  from django.template.defaulttags import IfChangedNode
7
8
  from django.template.loader_tags import IncludeNode
8
9
 
9
- _ContextValues = dict[str, Any] | Context
10
+ _ContextValues: TypeAlias = dict[str, Any] | Context
10
11
 
11
12
  class ContextPopException(Exception): ...
12
13
 
@@ -14,7 +15,12 @@ class ContextDict(dict[Any, Any]):
14
15
  context: BaseContext = ...
15
16
  def __init__(self, context: BaseContext, *args: Any, **kwargs: Any) -> None: ...
16
17
  def __enter__(self) -> ContextDict: ...
17
- def __exit__(self, *args: Any, **kwargs: Any) -> None: ...
18
+ def __exit__(
19
+ self,
20
+ exc_type: type[BaseException] | None,
21
+ exc_value: BaseException | None,
22
+ traceback: TracebackType | None,
23
+ ) -> None: ...
18
24
 
19
25
  class BaseContext(Iterable[Any]):
20
26
  def __init__(self, dict_: Any = ...) -> None: ...
@@ -4,7 +4,7 @@ from datetime import datetime
4
4
  from datetime import time as _time
5
5
  from typing import Any
6
6
 
7
- from django.utils.html import escape as escape # noqa: F401
7
+ from django.utils.html import escape as escape
8
8
  from django.utils.safestring import SafeText
9
9
 
10
10
  register: Any
@@ -1,5 +1,5 @@
1
1
  from collections.abc import Callable, Sequence
2
- from typing import Any
2
+ from typing import Any, TypeAlias
3
3
 
4
4
  from django.template.base import Origin
5
5
  from django.template.library import Library
@@ -8,7 +8,7 @@ from django.utils.safestring import SafeText
8
8
 
9
9
  from .base import Template
10
10
 
11
- _Loader = Any
11
+ _Loader: TypeAlias = Any
12
12
 
13
13
  class Engine:
14
14
  template_context_processors: tuple[Callable[..., Any]]
@@ -1,10 +1,10 @@
1
1
  from collections.abc import Callable
2
2
  from typing import Any, TypeVar, overload
3
- from typing_extensions import ParamSpec
4
3
 
5
4
  from django.template.base import FilterExpression, Origin, Parser, Token
6
5
  from django.template.context import Context
7
6
  from django.utils.safestring import SafeText
7
+ from typing_extensions import ParamSpec
8
8
 
9
9
  from .base import Node, Template
10
10
 
@@ -2,12 +2,10 @@ from typing import Any
2
2
 
3
3
  from django.http.request import HttpRequest
4
4
  from django.template.backends.base import _BaseTemplate
5
- from django.template.exceptions import ( # noqa: F401
6
- TemplateDoesNotExist as TemplateDoesNotExist,
7
- )
5
+ from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist
8
6
  from django.utils.safestring import SafeText
9
7
 
10
- from . import engines as engines # noqa: F401
8
+ from . import engines as engines
11
9
 
12
10
  def get_template(template_name: str, using: str | None = ...) -> _BaseTemplate: ...
13
11
  def select_template(
@@ -15,7 +15,7 @@ class ContentNotRenderedError(Exception): ...
15
15
  class SimpleTemplateResponse(HttpResponse):
16
16
  content: Any = ...
17
17
  closed: bool
18
- cookies: SimpleCookie # type: ignore [type-arg]
18
+ cookies: SimpleCookie
19
19
  status_code: int
20
20
  rendering_attrs: Any = ...
21
21
  template_name: list[str] | Template | str = ...
@@ -49,7 +49,7 @@ class TemplateResponse(SimpleTemplateResponse):
49
49
  closed: bool
50
50
  context: RequestContext # pyright: ignore[reportIncompatibleVariableOverride]
51
51
  context_data: dict[str, Any] | None
52
- cookies: SimpleCookie # type: ignore [type-arg]
52
+ cookies: SimpleCookie
53
53
  csrf_cookie_set: bool
54
54
  json: functools.partial[Any]
55
55
  redirect_chain: list[tuple[str, int]]
@@ -1,8 +1,8 @@
1
- from typing import Any
1
+ from typing import Any, TypeAlias
2
2
 
3
3
  from django.template.defaulttags import TemplateLiteral
4
4
 
5
- _Token = list[int] | int | str
5
+ _Token: TypeAlias = list[int] | int | str
6
6
 
7
7
  class TokenBase:
8
8
  id: Any = ...
@@ -3,7 +3,7 @@ from io import BytesIO
3
3
  from json import JSONEncoder
4
4
  from re import Pattern
5
5
  from types import TracebackType
6
- from typing import Any
6
+ from typing import Any, TypeAlias
7
7
 
8
8
  from django.contrib.auth.base_user import AbstractBaseUser
9
9
  from django.contrib.sessions.backends.base import SessionBase
@@ -47,12 +47,12 @@ class AsyncClientHandler(BaseHandler):
47
47
  def encode_multipart(boundary: str, data: dict[str, Any]) -> bytes: ...
48
48
  def encode_file(boundary: str, key: str, file: Any) -> list[bytes]: ...
49
49
 
50
- _RequestData = Any | None
50
+ _RequestData: TypeAlias = Any | None
51
51
 
52
52
  class RequestFactory:
53
53
  json_encoder: type[JSONEncoder]
54
54
  defaults: dict[str, str]
55
- cookies: SimpleCookie # type: ignore [type-arg]
55
+ cookies: SimpleCookie
56
56
  errors: BytesIO
57
57
  def __init__(
58
58
  self,
@@ -1,12 +1,12 @@
1
1
  from collections.abc import Sequence
2
2
  from html.parser import HTMLParser
3
- from typing import Any
3
+ from typing import Any, TypeAlias
4
4
 
5
5
  WHITESPACE: Any
6
6
 
7
7
  def normalize_whitespace(string: str) -> str: ...
8
8
 
9
- _ElementAttribute = tuple[str, str | None]
9
+ _ElementAttribute: TypeAlias = tuple[str, str | None]
10
10
 
11
11
  class Element:
12
12
  name: str | None = ...
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
 
3
- from django.core.signals import setting_changed as setting_changed # noqa: F401
3
+ from django.core.signals import setting_changed as setting_changed
4
4
 
5
5
  template_rendered: Any
6
6
  COMPLEX_OVERRIDE_SETTINGS: Any
@@ -1,12 +1,13 @@
1
1
  import threading
2
2
  import unittest
3
3
  from collections.abc import Callable, Iterable
4
+ from types import TracebackType
4
5
  from typing import Any, ClassVar, TypeVar, overload
5
6
 
6
7
  from django.core.exceptions import ImproperlyConfigured
7
8
  from django.core.handlers.wsgi import WSGIHandler
8
9
  from django.core.servers.basehttp import ThreadedWSGIServer, WSGIRequestHandler
9
- from django.db import connections as connections # noqa: F401
10
+ from django.db import connections as connections
10
11
  from django.db.backends.sqlite3.base import DatabaseWrapper
11
12
  from django.db.models import Model
12
13
  from django.db.models.query import ValuesQuerySet, _BaseQuerySet
@@ -35,7 +36,12 @@ class _AssertTemplateUsedContext:
35
36
  def test(self) -> Any: ...
36
37
  def message(self) -> Any: ...
37
38
  def __enter__(self) -> Any: ...
38
- def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> Any: ...
39
+ def __exit__(
40
+ self,
41
+ exc_type: type[BaseException] | None,
42
+ exc_value: BaseException | None,
43
+ traceback: TracebackType | None,
44
+ ) -> None: ...
39
45
 
40
46
  class _AssertTemplateNotUsedContext(_AssertTemplateUsedContext): ...
41
47
 
@@ -74,8 +80,8 @@ class SimpleTestCase(unittest.TestCase):
74
80
  ) -> None: ...
75
81
  def assertNotContains(
76
82
  self,
77
- response: HttpResponse,
78
- text: bytes | str,
83
+ response: HttpResponseBase,
84
+ text: bytes | int | str,
79
85
  status_code: int = ...,
80
86
  msg_prefix: str = ...,
81
87
  html: bool = ...,