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
@@ -3,8 +3,7 @@ from collections.abc import Callable, Iterable, Iterator, Mapping
3
3
  from contextlib import AbstractContextManager
4
4
  from decimal import Decimal
5
5
  from types import TracebackType
6
- from typing import Any, TypeVar, overload
7
- from typing_extensions import Self
6
+ from typing import Any, TypeAlias, TypeVar, overload
8
7
 
9
8
  from django.apps.registry import Apps
10
9
  from django.conf import LazySettings, Settings
@@ -12,9 +11,10 @@ from django.core.checks.registry import CheckRegistry
12
11
  from django.db import DefaultConnectionProxy
13
12
  from django.test.runner import DiscoverRunner
14
13
  from django.test.testcases import SimpleTestCase
14
+ from typing_extensions import Self
15
15
 
16
- _TestClass = type[SimpleTestCase]
17
- _DecoratedTest = Callable[..., Any] | _TestClass
16
+ _TestClass: TypeAlias = type[SimpleTestCase]
17
+ _DecoratedTest: TypeAlias = Callable[..., Any] | _TestClass
18
18
  _C = TypeVar("_C", bound=Callable[..., Any])
19
19
  _T = TypeVar("_T")
20
20
  _U = TypeVar("_U")
@@ -61,8 +61,8 @@ class TestContextDecorator:
61
61
  def __enter__(self) -> Any | None: ...
62
62
  def __exit__(
63
63
  self,
64
- exc_type: type[Exception] | None,
65
- exc_value: Exception | None,
64
+ exc_type: type[BaseException] | None,
65
+ exc_value: BaseException | None,
66
66
  traceback: TracebackType | None,
67
67
  ) -> None: ...
68
68
  def decorate_class(self, cls: _TestClassGeneric) -> _TestClassGeneric: ...
@@ -110,7 +110,12 @@ class CaptureQueriesContext:
110
110
  @property
111
111
  def captured_queries(self) -> list[dict[str, str]]: ...
112
112
  def __enter__(self) -> Self: ...
113
- def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
113
+ def __exit__(
114
+ self,
115
+ exc_type: type[BaseException] | None,
116
+ exc_value: BaseException | None,
117
+ traceback: TracebackType | None,
118
+ ) -> None: ...
114
119
 
115
120
  class ignore_warnings(TestContextDecorator):
116
121
  ignore_kwargs: dict[str, Any] = ...
@@ -1,11 +1,11 @@
1
1
  from collections.abc import Callable, Coroutine
2
- from typing import Any, overload
2
+ from typing import Any, TypeAlias, overload
3
3
 
4
4
  from ..conf.urls import IncludedURLConf
5
5
  from ..http.response import HttpResponseBase
6
6
  from .resolvers import URLPattern, URLResolver
7
7
 
8
- _ResponseType = (
8
+ _ResponseType: TypeAlias = (
9
9
  HttpResponseBase | Coroutine[Any, Any, HttpResponseBase] | Coroutine[Any, Any, None]
10
10
  )
11
11
 
@@ -1,4 +1,5 @@
1
1
  from collections.abc import Iterable, Sequence
2
+ from types import TracebackType
2
3
  from typing import Any
3
4
 
4
5
  class ArchiveException(Exception): ...
@@ -9,7 +10,12 @@ def extract(path: str, to_path: str = ...) -> None: ...
9
10
  class Archive:
10
11
  def __init__(self, file: str) -> None: ...
11
12
  def __enter__(self) -> Archive: ...
12
- def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
13
+ def __exit__(
14
+ self,
15
+ exc_type: type[BaseException] | None,
16
+ exc_value: BaseException | None,
17
+ traceback: TracebackType | None,
18
+ ) -> None: ...
13
19
  def extract(self, to_path: str = ...) -> None: ...
14
20
  def list(self) -> None: ...
15
21
  def close(self) -> None: ...
@@ -0,0 +1,38 @@
1
+ from abc import abstractmethod
2
+ from collections.abc import Iterator
3
+ from typing import Any
4
+
5
+ from django.db.backends.base.base import BaseDatabaseWrapper
6
+ from django.utils.functional import cached_property
7
+
8
+ class ConnectionProxy:
9
+ """Proxy for accessing a connection object's attributes."""
10
+
11
+ def __init__(self, connections: BaseConnectionHandler, alias: str) -> None: ...
12
+ def __getattr__(self, item: str) -> Any: ...
13
+ def __setattr__(self, name: str, value: Any) -> None: ...
14
+ def __delattr__(self, name: str) -> None: ...
15
+ def __contains__(self, key: str) -> bool: ...
16
+ def __eq__(self, other: object) -> bool: ...
17
+
18
+ class ConnectionDoesNotExist(Exception): ...
19
+
20
+ class BaseConnectionHandler:
21
+ settings_name: str | None
22
+ exception_class: type[Exception]
23
+ thread_critical: bool
24
+
25
+ def __init__(self, settings: dict[str, dict[str, Any]] | None = None) -> None: ...
26
+ @cached_property
27
+ def settings(self) -> dict[str, dict[str, Any]]: ...
28
+ def configure_settings(
29
+ self, settings: dict[str, dict[str, Any]] | None
30
+ ) -> dict[str, dict[str, Any]]: ...
31
+ @abstractmethod
32
+ def create_connection(self, alias: str) -> BaseDatabaseWrapper: ...
33
+ def __getitem__(self, alias: str) -> BaseDatabaseWrapper: ...
34
+ def __setitem__(self, key: str, value: BaseDatabaseWrapper) -> None: ...
35
+ def __delitem__(self, key: str) -> None: ...
36
+ def __iter__(self) -> Iterator[str]: ...
37
+ def all(self, initialized_only: bool = False) -> list[BaseDatabaseWrapper]: ...
38
+ def close_all(self) -> None: ...
@@ -7,6 +7,7 @@ from collections.abc import (
7
7
  MutableSet,
8
8
  )
9
9
  from typing import Any, Literal, TypeVar, overload
10
+
10
11
  from typing_extensions import Self
11
12
 
12
13
  _K = TypeVar("_K")
@@ -23,7 +23,7 @@ class TimeFormat(Formatter):
23
23
  def h(self) -> str: ...
24
24
  def H(self) -> str: ...
25
25
  def i(self) -> str: ...
26
- def O(self) -> str: ... # noqa:E741,E743
26
+ def O(self) -> str: ...
27
27
  def P(self) -> str: ...
28
28
  def s(self) -> str: ...
29
29
  def T(self) -> str: ...
@@ -40,9 +40,9 @@ class DateFormat(TimeFormat):
40
40
  def D(self) -> Any: ...
41
41
  def E(self) -> Any: ...
42
42
  def F(self) -> Any: ...
43
- def I(self) -> str: ... # noqa:E741,E743
43
+ def I(self) -> str: ...
44
44
  def j(self) -> int: ...
45
- def l(self) -> Any: ... # noqa:E741,E743
45
+ def l(self) -> Any: ...
46
46
  def L(self) -> bool: ...
47
47
  def m(self) -> str: ...
48
48
  def M(self) -> str: ...
@@ -1,5 +1,5 @@
1
1
  from collections.abc import Callable
2
- from typing import Any
2
+ from typing import Any, TypeAlias
3
3
 
4
4
  from django.http.request import HttpRequest
5
5
  from django.http.response import HttpResponse
@@ -32,7 +32,7 @@ class DeprecationInstanceCheck(type):
32
32
  deprecation_warning: type[Warning]
33
33
  def __instancecheck__(self, instance: Any) -> Any: ...
34
34
 
35
- GetResponseCallable = Callable[[HttpRequest], HttpResponse]
35
+ GetResponseCallable: TypeAlias = Callable[[HttpRequest], HttpResponse]
36
36
 
37
37
  class MiddlewareMixin:
38
38
  get_response: GetResponseCallable | None = ...
@@ -1,67 +1,100 @@
1
+ import sys
1
2
  from collections.abc import Callable
2
- from functools import wraps as wraps # noqa: F401
3
+ from functools import wraps as wraps
3
4
  from typing import Any, Generic, TypeVar, overload
4
- from typing_extensions import Self
5
5
 
6
6
  from django.db.models.base import Model
7
7
 
8
- def curry(_curried_func: Any, *args: Any, **kwargs: Any) -> Any: ...
8
+ if sys.version_info < (3, 8):
9
+ from typing_extensions import Protocol
10
+ else:
11
+ from typing import Protocol
9
12
 
10
13
  _T = TypeVar("_T")
11
14
 
12
15
  class cached_property(Generic[_T]):
13
16
  func: Callable[..., _T] = ...
14
- __doc__: Any = ...
15
17
  name: str = ...
16
- def __init__(self, func: Callable[..., _T], name: str | None = ...) -> None: ...
18
+ def __init__(self, func: Callable[..., _T], name: str = ...): ...
17
19
  @overload
18
- def __get__(self, instance: None, cls: type[Any] = ...) -> Self: ...
20
+ def __get__(self, instance: None, cls: type[Any] = ...) -> cached_property[_T]: ...
19
21
  @overload
20
22
  def __get__(self, instance: object, cls: type[Any] = ...) -> _T: ...
21
23
 
22
24
  class Promise: ...
23
25
 
24
- def lazy(
25
- func: Callable[..., Any] | type[str], *resultclasses: Any
26
- ) -> Callable[..., Any]: ...
27
- def lazystr(text: Any) -> Any: ...
26
+ class StrPromise(Promise, str):
27
+ """
28
+ This type is not available at runtime, and it's used when you need to mark
29
+ something explicitly as lazy string.
30
+
31
+ It's actually a Promise, but behaves mostly like str.
32
+ """
33
+
34
+ _C = TypeVar("_C", bound=Callable[..., Any])
35
+ _CS = TypeVar("_CS", bound=Callable[..., str])
36
+
37
+ def lazy(func: _C, *resultclasses: Any) -> _C: ...
38
+ def lazystr(text: Any) -> StrPromise: ...
28
39
  def keep_lazy(*resultclasses: Any) -> Callable[..., Any]: ...
29
- def keep_lazy_text(func: Callable[..., Any]) -> Callable[..., Any]: ...
40
+ def keep_lazy_text(func: _CS) -> _CS: ...
30
41
 
31
- empty: Any
42
+ empty: object
32
43
 
33
- def new_method_proxy(func: Any) -> Any: ...
44
+ def new_method_proxy(func: Callable[..., _T]) -> Callable[..., _T]: ...
34
45
 
35
46
  class LazyObject:
36
47
  def __init__(self) -> None: ...
37
- __getattr__: Any = ...
48
+ __getattr__: Callable[..., Any] = ...
38
49
  def __setattr__(self, name: str, value: Any) -> None: ...
39
50
  def __delattr__(self, name: str) -> None: ...
40
51
  def __reduce__(self) -> tuple[Callable[..., Any], tuple[Model]]: ...
41
- def __copy__(self) -> Any: ...
42
- def __deepcopy__(self, memo: Any) -> Any: ...
43
- __bytes__: Any = ...
44
- __bool__: Any = ...
45
- __dir__: Any = ...
52
+ def __copy__(self) -> LazyObject: ...
53
+ __bytes__: Callable[..., Any] = ...
54
+ __bool__: Callable[..., Any] = ...
55
+ __dir__: Callable[..., Any] = ...
46
56
  __class__: Any = ...
47
- __ne__: Any = ...
48
- __hash__: Any = ...
49
- __getitem__: Any = ...
50
- __setitem__: Any = ...
51
- __delitem__: Any = ...
52
- __iter__: Any = ...
53
- __len__: Any = ...
54
- __contains__: Any = ...
57
+ __ne__: Callable[..., Any] = ...
58
+ __hash__: Callable[..., Any] = ...
59
+ __getitem__: Callable[..., Any] = ...
60
+ __setitem__: Callable[..., Any] = ...
61
+ __delitem__: Callable[..., Any] = ...
62
+ __iter__: Callable[..., Any] = ...
63
+ __len__: Callable[..., Any] = ...
64
+ __contains__: Callable[..., Any] = ...
55
65
 
56
66
  def unpickle_lazyobject(wrapped: Model) -> Model: ...
57
67
 
58
68
  class SimpleLazyObject(LazyObject):
59
- def __init__(self, func: Callable[..., Any]) -> None: ...
60
- def __copy__(self) -> list[int]: ...
61
- def __deepcopy__(self, memo: dict[Any, Any]) -> list[int]: ...
69
+ def __init__(self, func: Callable[[], Any]) -> None: ...
70
+ def __copy__(self) -> SimpleLazyObject: ...
62
71
 
63
72
  _PartitionMember = TypeVar("_PartitionMember")
64
73
 
65
74
  def partition(
66
- predicate: Callable[..., Any], values: list[_PartitionMember]
75
+ predicate: Callable[[_PartitionMember], int | bool], values: list[_PartitionMember]
67
76
  ) -> tuple[list[_PartitionMember], list[_PartitionMember]]: ...
77
+
78
+ _Get = TypeVar("_Get", covariant=True)
79
+ _Self = TypeVar("_Self")
80
+
81
+ class classproperty(Generic[_Get]):
82
+ fget: Callable[..., _Get] | None = ...
83
+ @overload
84
+ def __init__(self) -> None: ...
85
+ @overload
86
+ def __init__(self, method: Callable[[_Self], _Get]) -> None: ...
87
+ def __get__(self, instance: _Self | None, cls: type[_Self] = ...) -> _Get: ...
88
+ def getter(self, method: Callable[[_Self], _Get]) -> classproperty[_Get]: ...
89
+
90
+ class _Getter(Protocol[_Get]):
91
+ """Type fake to declare some read-only properties (until `property` builtin is generic)
92
+
93
+ We can use something like `Union[_Getter[str], str]` in base class to avoid errors
94
+ when redefining attribute with property or property with attribute.
95
+ """
96
+
97
+ @overload
98
+ def __get__(self: _Self, __instance: None, __typeobj: type[Any] | None) -> _Self: ...
99
+ @overload
100
+ def __get__(self, __instance: Any, __typeobj: type[Any] | None) -> _Get: ...
@@ -1,4 +1,5 @@
1
1
  from typing import Any, overload
2
+
2
3
  from typing_extensions import Self
3
4
 
4
5
  class SafeData:
@@ -1,4 +1,3 @@
1
- from __future__ import print_function
2
1
 
3
2
  import types
4
3
  import typing
@@ -19,9 +18,9 @@ PY2 = False
19
18
  PY3 = True
20
19
  PY34: bool = ...
21
20
 
22
- string_types = (str,)
23
- integer_types = (int,)
24
- class_types = (type,)
21
+ string_types = ...
22
+ integer_types = ...
23
+ class_types = ...
25
24
  text_type = str
26
25
  binary_type = bytes
27
26
 
@@ -43,7 +42,7 @@ def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
43
42
  def get_method_self(meth: types.MethodType) -> object | None: ...
44
43
  def get_function_closure(
45
44
  fun: types.FunctionType,
46
- ) -> tuple[types._Cell, ...] | None: ... # pyright: ignore[reportAttributeAccessIssue]
45
+ ) -> tuple[Any, ...] | None: ...
47
46
  def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
48
47
  def get_function_defaults(fun: types.FunctionType) -> tuple[Any, ...] | None: ...
49
48
  def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ...
@@ -1,15 +1,14 @@
1
1
  import types
2
2
  from contextlib import ContextDecorator
3
- from datetime import date
3
+ from datetime import date, time, timezone
4
4
  from datetime import datetime as datetime
5
- from datetime import time
6
5
  from datetime import timedelta as timedelta
7
- from datetime import timezone
8
6
  from datetime import tzinfo as tzinfo
7
+ from typing import TypeAlias
9
8
 
10
9
  from pytz import BaseTzInfo
11
10
 
12
- _AnyTime = time | datetime
11
+ _AnyTime: TypeAlias = time | datetime
13
12
 
14
13
  class UTC(tzinfo):
15
14
  def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
@@ -55,9 +54,10 @@ class override(ContextDecorator):
55
54
  def __enter__(self) -> None: ...
56
55
  def __exit__(
57
56
  self,
58
- exc_type: type[BaseException],
59
- exc_value: BaseException,
60
- traceback: types.TracebackType,
57
+ exc_type: type[BaseException] | None,
58
+ exc_value: BaseException | None,
59
+ traceback: types.TracebackType | None,
60
+ /,
61
61
  ) -> None: ...
62
62
 
63
63
  def localtime(
@@ -7,5 +7,5 @@ def topological_sort_as_sets(
7
7
  dependency_graph: dict[Any, Any]
8
8
  ) -> Iterator[set[Any]]: ...
9
9
  def stable_topological_sort(
10
- l: Container[Any], dependency_graph: dict[Any, Any] # noqa:E741
10
+ l: Container[Any], dependency_graph: dict[Any, Any]
11
11
  ) -> list[Any]: ...
@@ -1,9 +1,11 @@
1
1
  import functools
2
2
  from collections.abc import Callable
3
3
  from contextlib import ContextDecorator
4
+ from types import TracebackType
4
5
  from typing import Any
5
6
 
6
7
  from django.http.request import HttpRequest
8
+ from django.utils.functional import StrPromise
7
9
 
8
10
  from . import trans_real as trans_real
9
11
 
@@ -42,19 +44,21 @@ ungettext = ngettext
42
44
  def pgettext(context: str, message: str) -> str: ...
43
45
  def npgettext(context: str, singular: str, plural: str, number: int) -> str: ...
44
46
 
45
- gettext_lazy = gettext
46
- ugettext_lazy = ugettext
47
- pgettext_lazy = pgettext
47
+ def gettext_lazy(message: str) -> StrPromise: ...
48
+
49
+ ugettext_lazy = gettext_lazy
50
+
51
+ def pgettext_lazy(context: str, message: str) -> StrPromise: ...
48
52
 
49
53
  def ngettext_lazy(
50
54
  singular: str, plural: str, number: int | str | None = ...
51
- ) -> str: ...
55
+ ) -> StrPromise: ...
52
56
 
53
57
  ungettext_lazy = ngettext_lazy
54
58
 
55
59
  def npgettext_lazy(
56
60
  context: str, singular: str, plural: str, number: int | str | None
57
- ) -> str: ...
61
+ ) -> StrPromise: ...
58
62
  def activate(language: str) -> None: ...
59
63
  def deactivate() -> None: ...
60
64
 
@@ -64,7 +68,12 @@ class override(ContextDecorator):
64
68
  def __init__(self, language: str | None, deactivate: bool = ...) -> None: ...
65
69
  old_language: str | None = ...
66
70
  def __enter__(self) -> None: ...
67
- def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
71
+ def __exit__(
72
+ self,
73
+ exc_type: type[BaseException] | None,
74
+ exc_value: BaseException | None,
75
+ traceback: TracebackType | None,
76
+ ) -> None: ...
68
77
 
69
78
  def get_language() -> str: ...
70
79
  def get_language_from_path(path: str) -> str | None: ...
@@ -1,9 +1,9 @@
1
1
  from collections.abc import Iterable, Sequence
2
- from typing import Any
2
+ from typing import Any, TypeAlias
3
3
 
4
4
  from django.db.models.sql.where import NothingNode
5
5
 
6
- _NodeChildren = Iterable[Node | NothingNode | Sequence[Any]]
6
+ _NodeChildren: TypeAlias = Iterable[Node | NothingNode | Sequence[Any]]
7
7
 
8
8
  class Node:
9
9
  children: list[Any]
@@ -1,4 +1,5 @@
1
1
  from xml.sax.saxutils import XMLGenerator
2
+ from xml.sax.xmlreader import AttributesImpl
2
3
 
3
4
  class UnserializableContentError(ValueError): ...
4
5
 
@@ -10,4 +11,4 @@ class SimplerXMLGenerator(XMLGenerator):
10
11
  attrs: dict[str, str] | None = ...,
11
12
  ) -> None: ...
12
13
  def characters(self, content: str) -> None: ...
13
- def startElement(self, name: str, attrs: dict[str, str]) -> None: ...
14
+ def startElement(self, name: str, attrs: AttributesImpl) -> None: ...
@@ -1 +1,3 @@
1
1
  from .generic.base import View as View
2
+
3
+ __all__ = ["View"]
@@ -1,9 +1,9 @@
1
+ from pathlib import Path
2
+
1
3
  from django.http.request import HttpRequest
2
4
  from django.http.response import HttpResponseForbidden
3
5
 
4
- CSRF_FAILURE_TEMPLATE: str
5
6
  CSRF_FAILURE_TEMPLATE_NAME: str
6
7
 
7
- def csrf_failure(
8
- request: HttpRequest, reason: str = ..., template_name: str = ...
9
- ) -> HttpResponseForbidden: ...
8
+ def builtin_template_path(name: str) -> Path: ...
9
+ def csrf_failure(request: HttpRequest, reason: str = ..., template_name: str = ...) -> HttpResponseForbidden: ...
@@ -1,77 +1,76 @@
1
- from collections.abc import Callable, MutableMapping
2
- from importlib.abc import SourceLoader
1
+ import re
2
+ from collections.abc import Callable, ItemsView, Iterator
3
+ from pathlib import Path
3
4
  from types import TracebackType
4
5
  from typing import Any
5
6
 
6
7
  from django.http.request import HttpRequest, QueryDict
7
8
  from django.http.response import Http404, HttpResponse
8
- from django.utils.safestring import SafeText
9
+ from django.template import Engine
10
+ from django.utils.safestring import SafeString
9
11
 
10
- DEBUG_ENGINE: Any
11
- HIDDEN_SETTINGS: Any
12
- CLEANSED_SUBSTITUTE: str
13
- CURRENT_DIR: Any
12
+ DEBUG_ENGINE: Engine
14
13
 
15
14
  class CallableSettingWrapper:
16
15
  def __init__(self, callable_setting: Callable[..., Any] | type[Any]) -> None: ...
17
16
 
18
- def cleanse_setting(key: int | str, value: Any) -> Any: ...
19
- def get_safe_settings() -> dict[str, Any]: ...
20
- def technical_500_response(
21
- request: Any, exc_type: Any, exc_value: Any, tb: Any, status_code: int = ...
22
- ) -> Any: ...
23
- def get_default_exception_reporter_filter() -> ExceptionReporterFilter: ...
24
- def get_exception_reporter_filter(
25
- request: HttpRequest | None,
26
- ) -> ExceptionReporterFilter: ...
17
+ class ExceptionCycleWarning(UserWarning): ...
27
18
 
28
- class ExceptionReporterFilter:
29
- def get_post_parameters(self, request: Any) -> Any: ...
30
- def get_traceback_frame_variables(self, request: Any, tb_frame: Any) -> Any: ...
19
+ def technical_500_response(
20
+ request: HttpRequest,
21
+ exc_type: type[BaseException] | None,
22
+ exc_value: BaseException | None,
23
+ tb: TracebackType | None,
24
+ status_code: int = ...,
25
+ ) -> HttpResponse: ...
26
+ def get_default_exception_reporter_filter() -> SafeExceptionReporterFilter: ...
27
+ def get_exception_reporter_filter(request: HttpRequest | None) -> SafeExceptionReporterFilter: ...
31
28
 
32
- class SafeExceptionReporterFilter(ExceptionReporterFilter):
29
+ class SafeExceptionReporterFilter:
30
+ cleansed_substitute: str
31
+ hidden_settings: re.Pattern[str]
32
+ def cleanse_setting(self, key: int | str, value: Any) -> Any: ...
33
+ def get_safe_settings(self) -> dict[str, Any]: ...
34
+ def get_safe_request_meta(self, request: HttpRequest) -> dict[str, Any]: ...
35
+ def get_safe_cookies(self, request: HttpRequest) -> dict[str, Any]: ...
33
36
  def is_active(self, request: HttpRequest | None) -> bool: ...
34
- def get_cleansed_multivaluedict(
35
- self, request: HttpRequest, multivaluedict: QueryDict
36
- ) -> QueryDict: ...
37
- def get_post_parameters(
38
- self, request: HttpRequest | None
39
- ) -> MutableMapping[str, Any]: ...
37
+ def get_cleansed_multivaluedict(self, request: HttpRequest, multivaluedict: QueryDict) -> QueryDict: ...
38
+ def get_post_parameters(self, request: HttpRequest | None) -> dict[str, Any]: ...
40
39
  def cleanse_special_types(self, request: HttpRequest | None, value: Any) -> Any: ...
41
- def get_traceback_frame_variables(self, request: Any, tb_frame: Any) -> Any: ...
40
+ def get_traceback_frame_variables(self, request: Any, tb_frame: Any) -> ItemsView[str, Any]: ...
42
41
 
43
42
  class ExceptionReporter:
44
- request: HttpRequest | None = ...
45
- filter: ExceptionReporterFilter = ...
46
- exc_type: type[BaseException] | None = ...
47
- exc_value: str | None = ...
48
- tb: TracebackType | None = ...
49
- is_email: bool = ...
50
- template_info: None = ...
51
- template_does_not_exist: bool = ...
52
- postmortem: None = ...
43
+ request: HttpRequest | None
44
+ filter: SafeExceptionReporterFilter
45
+ exc_type: type[BaseException] | None
46
+ exc_value: BaseException | None
47
+ tb: TracebackType | None
48
+ is_email: bool
49
+ template_info: Any | None
50
+ template_does_not_exist: bool
51
+ postmortem: Any | None
52
+ @property
53
+ def html_template_path(self) -> Path: ...
54
+ @property
55
+ def text_template_path(self) -> Path: ...
53
56
  def __init__(
54
57
  self,
55
58
  request: HttpRequest | None,
56
59
  exc_type: type[BaseException] | None,
57
- exc_value: str | BaseException | None,
60
+ exc_value: BaseException | None,
58
61
  tb: TracebackType | None,
59
62
  is_email: bool = ...,
60
63
  ) -> None: ...
61
64
  def get_traceback_data(self) -> dict[str, Any]: ...
62
- def get_traceback_html(self) -> SafeText: ...
63
- def get_traceback_text(self) -> SafeText: ...
65
+ def get_traceback_html(self) -> SafeString: ...
66
+ def get_traceback_text(self) -> SafeString: ...
64
67
  def get_traceback_frames(self) -> list[Any]: ...
65
- def _get_lines_from_file(
66
- self,
67
- filename: str,
68
- lineno: int,
69
- context_lines: int,
70
- loader: SourceLoader | None = ...,
71
- module_name: str | None = ...,
72
- ) -> Any: ...
68
+ def get_exception_traceback_frames(
69
+ self, exc_value: BaseException | None, tb: TracebackType | None
70
+ ) -> Iterator[dict[str, Any]]: ...
73
71
 
74
- def technical_404_response(
75
- request: HttpRequest, exception: Http404
76
- ) -> HttpResponse: ...
72
+ def technical_404_response(request: HttpRequest, exception: Http404) -> HttpResponse: ...
77
73
  def default_urlconf(request: HttpResponse | None) -> HttpResponse: ...
74
+ def builtin_template_path(name: str) -> Path: ...
75
+ def get_caller(request: HttpRequest) -> str: ...
76
+ def get_exception_reporter_class(request: HttpRequest) -> ExceptionReporter: ...
@@ -4,7 +4,7 @@ from typing import Any, TypeVar
4
4
  _F = TypeVar("_F", bound=Callable[..., Any])
5
5
 
6
6
  def cache_page(
7
- timeout: float, *, cache: Any | None = ..., key_prefix: Any | None = ...
7
+ timeout: float | None, *, cache: Any | None = ..., key_prefix: Any | None = ...
8
8
  ) -> Callable[[_F], _F]: ...
9
9
  def cache_control(**kwargs: Any) -> Callable[[_F], _F]: ...
10
10
  def never_cache(view_func: _F) -> _F: ...
@@ -1,7 +1,9 @@
1
1
  from collections.abc import Callable
2
- from typing import Any, TypeVar
2
+ from typing import Any, Literal, TypeVar
3
3
 
4
4
  _F = TypeVar("_F", bound=Callable[..., Any])
5
5
 
6
+ coroutine_functions_to_sensitive_variables: dict[int, Literal["__ALL__"] | tuple[str, ...]]
7
+
6
8
  def sensitive_variables(*variables: str) -> Callable[[_F], _F]: ...
7
9
  def sensitive_post_parameters(*parameters: str) -> Callable[[_F], _F]: ...
@@ -10,16 +10,13 @@ ERROR_404_TEMPLATE_NAME: str
10
10
  ERROR_403_TEMPLATE_NAME: str
11
11
  ERROR_400_TEMPLATE_NAME: str
12
12
  ERROR_500_TEMPLATE_NAME: str
13
+ ERROR_PAGE_TEMPLATE: str
13
14
 
14
15
  def page_not_found(
15
16
  request: HttpRequest, exception: Exception | None, template_name: str = ...
16
17
  ) -> HttpResponseNotFound: ...
17
- def server_error(
18
- request: HttpRequest, template_name: str = ...
19
- ) -> HttpResponseServerError: ...
20
- def bad_request(
21
- request: HttpRequest, exception: Exception, template_name: str = ...
22
- ) -> HttpResponseBadRequest: ...
18
+ def server_error(request: HttpRequest, template_name: str = ...) -> HttpResponseServerError: ...
19
+ def bad_request(request: HttpRequest, exception: Exception, template_name: str = ...) -> HttpResponseBadRequest: ...
23
20
  def permission_denied(
24
21
  request: HttpRequest, exception: Exception, template_name: str = ...
25
22
  ) -> HttpResponseForbidden: ...
@@ -1,6 +1,6 @@
1
1
  import datetime
2
2
  from collections.abc import Sequence
3
- from typing import Any
3
+ from typing import Any, TypeAlias
4
4
 
5
5
  from django.db import models
6
6
  from django.http import HttpRequest, HttpResponse
@@ -53,7 +53,9 @@ class DateMixin:
53
53
  def get_allow_future(self) -> bool: ...
54
54
  def uses_datetime_field(self) -> bool: ...
55
55
 
56
- DatedItems = tuple[Sequence[datetime.date] | None, Sequence[object], dict[str, Any]]
56
+ DatedItems: TypeAlias = tuple[
57
+ Sequence[datetime.date] | None, Sequence[object], dict[str, Any]
58
+ ]
57
59
 
58
60
  class BaseDateListView(MultipleObjectMixin, DateMixin, View):
59
61
  date_list_period: str = ...