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,6 +1,5 @@
1
1
  from collections.abc import Callable, Mapping, Sequence
2
- from typing import Any, Protocol, TypeVar, overload
3
- from typing_extensions import Literal
2
+ from typing import Any, Literal, Protocol, TypeVar, overload
4
3
 
5
4
  from django.db.models import Manager, QuerySet
6
5
  from django.db.models.base import Model
@@ -1,7 +1,16 @@
1
1
  from collections.abc import Iterator, Mapping
2
- from typing import Any
2
+ from typing import Any, Protocol
3
3
 
4
- from django.template.base import Template
4
+ from django.http.request import HttpRequest
5
+ from django.utils.safestring import SafeText
6
+
7
+ # Source: https://github.com/django/deps/blob/main/final/0182-multiple-template-engines.rst#backends-api
8
+ class _BaseTemplate(Protocol):
9
+ def render(
10
+ self,
11
+ context: Mapping[str, Any] | None = ...,
12
+ request: HttpRequest | None = ...,
13
+ ) -> SafeText | str: ...
5
14
 
6
15
  class BaseEngine:
7
16
  name: str = ...
@@ -9,9 +18,9 @@ class BaseEngine:
9
18
  app_dirs: bool = ...
10
19
  def __init__(self, params: Mapping[str, Any]) -> None: ...
11
20
  @property
12
- def app_dirname(self) -> str | None: ...
13
- def from_string(self, template_code: str) -> Template: ...
14
- def get_template(self, template_name: str) -> Template | None: ...
21
+ def app_dirname(self) -> str: ...
22
+ def from_string(self, template_code: str) -> _BaseTemplate: ...
23
+ def get_template(self, template_name: str) -> _BaseTemplate: ...
15
24
  @property
16
25
  def template_dirs(self) -> tuple[str]: ...
17
26
  def iter_template_filenames(self, template_name: str) -> Iterator[str]: ...
@@ -1,8 +1,12 @@
1
- from collections.abc import Iterator
2
- from typing import Any
1
+ from collections.abc import Iterator, Mapping
2
+ from typing import Any, NoReturn
3
+ from typing_extensions import override
3
4
 
5
+ from django.http.request import HttpRequest
6
+ from django.template import base
4
7
  from django.template.engine import Engine
5
8
  from django.template.exceptions import TemplateDoesNotExist
9
+ from django.utils.safestring import SafeText
6
10
 
7
11
  from .base import BaseEngine
8
12
 
@@ -12,10 +16,27 @@ class DjangoTemplates(BaseEngine):
12
16
  def get_templatetag_libraries(
13
17
  self, custom_libraries: dict[str, str]
14
18
  ) -> dict[str, str]: ...
19
+ @override
20
+ def from_string(self, template_code: str) -> Template: ...
21
+ @override
22
+ def get_template(self, template_name: str) -> Template: ...
23
+
24
+ class Template:
25
+ template: base.Template
26
+ backend: DjangoTemplates
27
+ def __init__(self, template: base.Template, backend: DjangoTemplates) -> None: ...
28
+ @property
29
+ def origin(self) -> base.Origin: ...
30
+ def render(
31
+ self,
32
+ context: Mapping[str, Any] | None = ...,
33
+ request: HttpRequest | None = ...,
34
+ ) -> SafeText: ...
15
35
 
16
36
  def copy_exception(
17
37
  exc: TemplateDoesNotExist, backend: DjangoTemplates | None = ...
18
38
  ) -> TemplateDoesNotExist: ...
19
- def reraise(exc: TemplateDoesNotExist, backend: DjangoTemplates) -> Any: ...
39
+ def reraise(exc: TemplateDoesNotExist, backend: DjangoTemplates) -> NoReturn: ...
40
+ def get_template_tag_modules() -> Iterator[tuple[str, str]]: ...
20
41
  def get_installed_libraries() -> dict[str, str]: ...
21
42
  def get_package_libraries(pkg: Any) -> Iterator[str]: ...
@@ -1,20 +1,21 @@
1
1
  import string
2
+ from collections.abc import Mapping
2
3
  from typing import Any
4
+ from typing_extensions import override
3
5
 
4
6
  from django.http.request import HttpRequest
5
7
 
6
8
  from .base import BaseEngine
7
9
 
8
10
  class TemplateStrings(BaseEngine):
9
- template_dirs: tuple[str]
10
- def __init__(
11
- self, params: dict[str, dict[Any, Any] | list[Any] | bool | str]
12
- ) -> None: ...
11
+ @override
12
+ def from_string(self, template_code: str) -> Template: ...
13
+ @override
14
+ def get_template(self, template_name: str) -> Template: ...
13
15
 
14
16
  class Template(string.Template):
15
- template: str
16
17
  def render(
17
18
  self,
18
- context: dict[str, str] | None = ...,
19
+ context: Mapping[str, Any] | None = ...,
19
20
  request: HttpRequest | None = ...,
20
21
  ) -> str: ...
@@ -1,16 +1,34 @@
1
- from collections.abc import Callable
1
+ from collections.abc import Callable, Mapping
2
2
  from typing import Any
3
+ from typing_extensions import override
3
4
 
5
+ from django.http.request import HttpRequest
6
+ from django.template import base
4
7
  from django.template.exceptions import TemplateSyntaxError
8
+ from django.utils.safestring import SafeText
5
9
 
6
10
  from .base import BaseEngine
7
11
 
8
12
  class Jinja2(BaseEngine):
9
13
  context_processors: list[str] = ...
10
- def __init__(self, params: dict[str, Any]) -> None: ...
14
+ @override
15
+ def from_string(self, template_code: str) -> Template: ...
16
+ @override
17
+ def get_template(self, template_name: str) -> Template: ...
11
18
  @property
12
19
  def template_context_processors(self) -> list[Callable[..., Any]]: ...
13
20
 
21
+ class Template:
22
+ template: base.Template
23
+ backend: Jinja2
24
+ origin: Origin
25
+ def __init__(self, template: base.Template, backend: Jinja2) -> None: ...
26
+ def render(
27
+ self,
28
+ context: Mapping[str, Any] | None = ...,
29
+ request: HttpRequest | None = ...,
30
+ ) -> SafeText: ...
31
+
14
32
  class Origin:
15
33
  name: str = ...
16
34
  template_name: str | None = ...
@@ -1,9 +1,9 @@
1
- from typing import Any
1
+ from collections.abc import Callable
2
2
 
3
3
  from django.http.request import HttpRequest
4
4
  from django.utils.safestring import SafeText
5
5
 
6
6
  def csrf_input(request: HttpRequest) -> SafeText: ...
7
7
 
8
- csrf_input_lazy: Any
9
- csrf_token_lazy: Any
8
+ csrf_input_lazy: Callable[[HttpRequest], SafeText]
9
+ csrf_token_lazy: Callable[[HttpRequest], SafeText]
@@ -65,9 +65,9 @@ class Template:
65
65
  def __iter__(self) -> None: ...
66
66
  def render(
67
67
  self,
68
- context: Context | dict[str, Any] | None = ...,
68
+ context: Context,
69
69
  request: HttpRequest | None = ...,
70
- ) -> Any: ...
70
+ ) -> SafeText: ...
71
71
  def compile_nodelist(self) -> NodeList: ...
72
72
  def get_exception_info(
73
73
  self, exception: Exception, token: Token
@@ -68,8 +68,8 @@ class RequestContext(Context):
68
68
  dicts: list[dict[str, str]]
69
69
  render_context: RenderContext
70
70
  template_name: str | None
71
- use_l10n: None
72
- use_tz: None
71
+ use_l10n: None # pyright: ignore[reportIncompatibleVariableOverride]
72
+ use_tz: None # pyright: ignore[reportIncompatibleVariableOverride]
73
73
  request: HttpRequest = ...
74
74
  def __init__(
75
75
  self,
@@ -1,14 +1,13 @@
1
1
  from collections.abc import Callable
2
2
  from typing import Any
3
3
 
4
- from django.core.handlers.wsgi import WSGIRequest
5
4
  from django.http.request import HttpRequest
6
5
  from django.utils.functional import SimpleLazyObject
7
6
 
8
7
  def csrf(request: HttpRequest) -> dict[str, SimpleLazyObject]: ...
9
8
  def debug(request: HttpRequest) -> dict[str, Callable[..., Any] | bool]: ...
10
9
  def i18n(
11
- request: WSGIRequest,
10
+ request: HttpRequest,
12
11
  ) -> dict[str, list[tuple[str, str]] | bool | str]: ...
13
12
  def tz(request: HttpRequest) -> dict[str, str]: ...
14
13
  def static(request: HttpRequest) -> dict[str, str]: ...
@@ -1,5 +1,6 @@
1
1
  from collections.abc import Callable
2
- from typing import Any
2
+ from typing import Any, TypeVar, overload
3
+ from typing_extensions import ParamSpec
3
4
 
4
5
  from django.template.base import FilterExpression, Origin, Parser, Token
5
6
  from django.template.context import Context
@@ -7,40 +8,103 @@ from django.utils.safestring import SafeText
7
8
 
8
9
  from .base import Node, Template
9
10
 
11
+ T = TypeVar("T")
12
+ P = ParamSpec("P")
13
+
10
14
  class InvalidTemplateLibrary(Exception): ...
11
15
 
12
16
  class Library:
13
17
  filters: dict[str, Callable[..., Any]] = ...
14
18
  tags: dict[str, Callable[..., Any]] = ...
15
19
  def __init__(self) -> None: ...
20
+
21
+ # Both arguments None
22
+ @overload
23
+ def tag(
24
+ self,
25
+ name: None = ...,
26
+ compile_function: None = ...,
27
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
28
+ # Only name as function
29
+ @overload
30
+ def tag(
31
+ self,
32
+ name: Callable[P, T],
33
+ compile_function: None = ...,
34
+ ) -> Callable[P, T]: ...
35
+ # Only name as string
36
+ @overload
16
37
  def tag(
17
38
  self,
18
- name: Callable[..., Any] | str | None = ...,
19
- compile_function: Callable[..., Any] | str | None = ...,
20
- ) -> Callable[..., Any]: ...
21
- def tag_function(self, func: Callable[..., Any]) -> Callable[..., Any]: ...
39
+ name: str,
40
+ compile_function: None = ...,
41
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
42
+ # Both arguments specified
43
+ @overload
44
+ def tag(
45
+ self,
46
+ name: str,
47
+ compile_function: Callable[P, T],
48
+ ) -> Callable[P, T]: ...
49
+ def tag_function(self, func: Callable[P, T]) -> Callable[P, T]: ...
50
+
51
+ # Both arguments None
52
+ @overload
53
+ def filter(
54
+ self,
55
+ name: None = ...,
56
+ filter_func: None = ...,
57
+ **flags: Any,
58
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
59
+ # Only name as string
60
+ @overload
22
61
  def filter(
23
62
  self,
24
- name: Callable[..., Any] | str | None = ...,
25
- filter_func: Callable[..., Any] | str | None = ...,
26
- **flags: Any
27
- ) -> Callable[..., Any]: ...
28
- def filter_function(
29
- self, func: Callable[..., Any], **flags: Any
30
- ) -> Callable[..., Any]: ...
63
+ name: str = ...,
64
+ filter_func: None = ...,
65
+ **flags: Any,
66
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
67
+ # Only name as callable
68
+ @overload
69
+ def filter(
70
+ self,
71
+ name: Callable[P, T],
72
+ filter_func: None = ...,
73
+ **flags: Any,
74
+ ) -> Callable[P, T]: ...
75
+ # Both arguments
76
+ @overload
77
+ def filter(
78
+ self,
79
+ name: str,
80
+ filter_func: Callable[P, T],
81
+ **flags: Any,
82
+ ) -> Callable[P, T]: ...
83
+ def filter_function(self, func: Callable[P, T], **flags: Any) -> Callable[P, T]: ...
84
+
85
+ # func is None
86
+ @overload
87
+ def simple_tag(
88
+ self,
89
+ func: None = ...,
90
+ takes_context: bool | None = ...,
91
+ name: str | None = ...,
92
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
93
+ # func is callable
94
+ @overload
31
95
  def simple_tag(
32
96
  self,
33
- func: Callable[..., Any] | str | None = ...,
97
+ func: Callable[P, T],
34
98
  takes_context: bool | None = ...,
35
99
  name: str | None = ...,
36
- ) -> Callable[..., Any]: ...
100
+ ) -> Callable[P, T]: ...
37
101
  def inclusion_tag(
38
102
  self,
39
103
  filename: Template | str,
40
104
  func: None = ...,
41
105
  takes_context: bool | None = ...,
42
106
  name: str | None = ...,
43
- ) -> Callable[..., Any]: ...
107
+ ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
44
108
 
45
109
  class TagHelperNode(Node):
46
110
  func: Any = ...
@@ -1,19 +1,21 @@
1
1
  from typing import Any
2
2
 
3
3
  from django.http.request import HttpRequest
4
+ from django.template.backends.base import _BaseTemplate
4
5
  from django.template.exceptions import ( # noqa: F401
5
6
  TemplateDoesNotExist as TemplateDoesNotExist,
6
7
  )
8
+ from django.utils.safestring import SafeText
7
9
 
8
10
  from . import engines as engines # noqa: F401
9
11
 
10
- def get_template(template_name: str, using: str | None = ...) -> Any: ...
12
+ def get_template(template_name: str, using: str | None = ...) -> _BaseTemplate: ...
11
13
  def select_template(
12
14
  template_name_list: list[str] | str, using: str | None = ...
13
- ) -> Any: ...
15
+ ) -> _BaseTemplate: ...
14
16
  def render_to_string(
15
17
  template_name: list[str] | str,
16
18
  context: dict[str, Any] | None = ...,
17
19
  request: HttpRequest | None = ...,
18
20
  using: str | None = ...,
19
- ) -> str: ...
21
+ ) -> SafeText: ...
@@ -15,7 +15,7 @@ class ContentNotRenderedError(Exception): ...
15
15
  class SimpleTemplateResponse(HttpResponse):
16
16
  content: Any = ...
17
17
  closed: bool
18
- cookies: SimpleCookie[Any]
18
+ cookies: SimpleCookie # type: ignore [type-arg]
19
19
  status_code: int
20
20
  rendering_attrs: Any = ...
21
21
  template_name: list[str] | Template | str = ...
@@ -47,9 +47,9 @@ class SimpleTemplateResponse(HttpResponse):
47
47
  class TemplateResponse(SimpleTemplateResponse):
48
48
  client: Client
49
49
  closed: bool
50
- context: RequestContext
50
+ context: RequestContext # pyright: ignore[reportIncompatibleVariableOverride]
51
51
  context_data: dict[str, Any] | None
52
- cookies: SimpleCookie[Any]
52
+ cookies: SimpleCookie # type: ignore [type-arg]
53
53
  csrf_cookie_set: bool
54
54
  json: functools.partial[Any]
55
55
  redirect_chain: list[tuple[str, int]]
@@ -1,4 +1,5 @@
1
- import collections
1
+ from collections.abc import Iterator
2
+ from pathlib import Path
2
3
  from typing import Any
3
4
 
4
5
  from django.core.exceptions import ImproperlyConfigured
@@ -7,10 +8,11 @@ from django.template.backends.base import BaseEngine
7
8
  class InvalidTemplateEngineError(ImproperlyConfigured): ...
8
9
 
9
10
  class EngineHandler:
10
- templates: collections.OrderedDict[Any, Any]
11
11
  def __init__(self, templates: list[dict[str, Any]] = ...) -> None: ...
12
+ @property
13
+ def templates(self) -> dict[str, dict[str, Any]]: ...
12
14
  def __getitem__(self, alias: str) -> BaseEngine: ...
13
- def __iter__(self) -> Any: ...
15
+ def __iter__(self) -> Iterator[BaseEngine]: ...
14
16
  def all(self) -> list[BaseEngine]: ...
15
17
 
16
- def get_app_template_dirs(dirname: str) -> tuple[Any, ...]: ...
18
+ def get_app_template_dirs(dirname: str) -> tuple[Path, ...]: ...