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
@@ -1,11 +1,11 @@
1
1
  from collections.abc import Sequence
2
- from email._policybase import Policy # type: ignore
2
+ from email._policybase import Policy
3
3
  from email.message import Message
4
4
  from email.mime.base import MIMEBase
5
5
  from email.mime.message import MIMEMessage
6
6
  from email.mime.multipart import MIMEMultipart
7
7
  from email.mime.text import MIMEText
8
- from typing import Any, overload
8
+ from typing import Any, TypeAlias, overload
9
9
 
10
10
  utf8_charset: Any
11
11
  utf8_charset_qp: Any
@@ -27,13 +27,13 @@ class MIMEMixin: ...
27
27
  class SafeMIMEMessage(MIMEMixin, MIMEMessage):
28
28
  defects: list[Any]
29
29
  epilogue: None # pyright: ignore[reportIncompatibleVariableOverride]
30
- policy: Policy # type: ignore [no-any-unimported]
30
+ policy: Policy
31
31
  preamble: None # pyright: ignore[reportIncompatibleVariableOverride]
32
32
 
33
33
  class SafeMIMEText(MIMEMixin, MIMEText):
34
34
  defects: list[Any]
35
35
  epilogue: None # pyright: ignore[reportIncompatibleVariableOverride]
36
- policy: Policy # type: ignore [no-any-unimported]
36
+ policy: Policy
37
37
  preamble: None # pyright: ignore[reportIncompatibleVariableOverride]
38
38
  encoding: str = ...
39
39
  def __init__(
@@ -43,7 +43,7 @@ class SafeMIMEText(MIMEMixin, MIMEText):
43
43
  class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
44
44
  defects: list[Any]
45
45
  epilogue: None # pyright: ignore[reportIncompatibleVariableOverride]
46
- policy: Policy # type: ignore [no-any-unimported]
46
+ policy: Policy
47
47
  preamble: None # pyright: ignore[reportIncompatibleVariableOverride]
48
48
  encoding: str = ...
49
49
  def __init__(
@@ -55,8 +55,8 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
55
55
  **_params: Any
56
56
  ) -> None: ...
57
57
 
58
- _AttachmentContent = bytes | EmailMessage | Message | SafeMIMEText | str
59
- _AttachmentTuple = (
58
+ _AttachmentContent: TypeAlias = bytes | EmailMessage | Message | SafeMIMEText | str
59
+ _AttachmentTuple: TypeAlias = (
60
60
  tuple[str, _AttachmentContent]
61
61
  | tuple[str | None, _AttachmentContent, str]
62
62
  | tuple[str, _AttachmentContent, None]
@@ -2,22 +2,24 @@ from typing import Any
2
2
 
3
3
  from .base import BaseCommand as BaseCommand
4
4
  from .base import CommandError as CommandError
5
+ from .base import CommandParser as CommandParser
6
+ from .base import handle_default_options as handle_default_options
5
7
 
6
8
  def find_commands(management_dir: str) -> list[str]: ...
7
9
  def load_command_class(app_name: str, name: str) -> BaseCommand: ...
8
10
  def get_commands() -> dict[str, str]: ...
9
11
  def call_command(
10
- command_name: tuple[str] | BaseCommand | str, *args: Any, **options: Any
11
- ) -> str: ...
12
+ command_name: str | BaseCommand, *args: Any, **options: Any
13
+ ) -> str | None: ...
12
14
 
13
15
  class ManagementUtility:
14
- argv: list[str] = ...
15
- prog_name: str = ...
16
- settings_exception: None = ...
17
- def __init__(self, argv: list[str] = ...) -> None: ...
18
- def main_help_text(self, commands_only: bool = ...) -> Any: ...
16
+ argv: list[str]
17
+ prog_name: str
18
+ settings_exception: None
19
+ def __init__(self, argv: list[str] | None = ...) -> None: ...
20
+ def main_help_text(self, commands_only: bool = ...) -> str: ...
19
21
  def fetch_command(self, subcommand: str) -> BaseCommand: ...
20
22
  def autocomplete(self) -> None: ...
21
23
  def execute(self) -> None: ...
22
24
 
23
- def execute_from_command_line(argv: list[str] = ...) -> None: ...
25
+ def execute_from_command_line(argv: list[str] | None = ...) -> None: ...
@@ -1,60 +1,69 @@
1
1
  from argparse import ArgumentParser, HelpFormatter, Namespace
2
- from collections.abc import Callable
3
- from io import StringIO, TextIOBase, TextIOWrapper
4
- from typing import Any
2
+ from collections.abc import Callable, Sequence
3
+ from typing import Any, NoReturn, TextIO
5
4
 
6
5
  from django.apps.config import AppConfig
7
6
  from django.core.management.color import Style
8
7
 
9
- class CommandError(Exception): ...
8
+ class CommandError(Exception):
9
+ returncode: int
10
+ def __init__(self, *args: Any, returncode: int = ..., **kwargs: Any) -> None: ...
11
+
10
12
  class SystemCheckError(CommandError): ...
11
13
 
12
14
  class CommandParser(ArgumentParser):
13
- missing_args_message: None = ...
14
- called_from_command_line: bool = ...
15
- def __init__(self, **kwargs: Any) -> None: ...
16
- def error(self, message: str) -> Any: ...
15
+ missing_args_message: str | None
16
+ called_from_command_line: bool | None
17
+ def __init__(
18
+ self,
19
+ *,
20
+ missing_args_message: str | None = None,
21
+ called_from_command_line: bool | None = ...,
22
+ **kwargs: Any,
23
+ ) -> None: ...
24
+ def error(self, message: str) -> NoReturn: ...
17
25
 
18
26
  def handle_default_options(options: Namespace) -> None: ...
19
27
  def no_translations(handle_func: Callable[..., Any]) -> Callable[..., Any]: ...
20
28
 
21
29
  class DjangoHelpFormatter(HelpFormatter): ...
22
30
 
23
- class OutputWrapper(TextIOBase):
31
+ class OutputWrapper:
24
32
  @property
25
- def style_func(self) -> Any: ...
33
+ def style_func(self) -> Callable[[str], str]: ...
26
34
  @style_func.setter
27
- def style_func(self, style_func: Callable[[str], str]) -> Any: ...
35
+ def style_func(self, style_func: Callable[[str], str]) -> None: ...
28
36
  ending: str = ...
29
37
  def __init__(
30
38
  self,
31
- out: StringIO | TextIOWrapper,
32
- style_func: Callable[[str], str] | None = ...,
39
+ out: TextIO,
33
40
  ending: str = ...,
34
41
  ) -> None: ...
35
- def __getattr__(self, name: str) -> Callable[..., Any]: ...
42
+ def __getattr__(self, name: str) -> Any: ...
43
+ def flush(self) -> None: ...
36
44
  def isatty(self) -> bool: ...
37
- def write( # type: ignore[override]
45
+ def write(
38
46
  self,
39
- msg: str,
47
+ msg: str = ...,
40
48
  style_func: Callable[[str], str] | None = ...,
41
49
  ending: str | None = ...,
42
50
  ) -> None: ...
43
51
 
44
52
  class BaseCommand:
45
- help: str = ...
46
- output_transaction: bool = ...
47
- requires_migrations_checks: bool = ...
48
- requires_system_checks: bool = ...
49
- base_stealth_options: tuple[str, ...] = ...
50
- stealth_options: tuple[str, ...] = ...
51
- stdout: OutputWrapper = ...
52
- stderr: OutputWrapper = ...
53
- style: Style = ...
53
+ help: str
54
+ output_transaction: bool
55
+ requires_migrations_checks: bool
56
+ requires_system_checks: str
57
+ base_stealth_options: tuple[str, ...]
58
+ stealth_options: tuple[str, ...]
59
+ suppressed_base_arguments: set[str]
60
+ stdout: OutputWrapper
61
+ stderr: OutputWrapper
62
+ style: Style
54
63
  def __init__(
55
64
  self,
56
- stdout: StringIO | None = ...,
57
- stderr: StringIO | None = ...,
65
+ stdout: TextIO | None = ...,
66
+ stderr: TextIO | None = ...,
58
67
  no_color: bool = ...,
59
68
  force_color: bool = ...,
60
69
  ) -> None: ...
@@ -63,9 +72,13 @@ class BaseCommand:
63
72
  self, prog_name: str, subcommand: str, **kwargs: Any
64
73
  ) -> CommandParser: ...
65
74
  def add_arguments(self, parser: CommandParser) -> None: ...
75
+ def add_base_argument(
76
+ self, parser: CommandParser, *args: Any, **kwargs: Any
77
+ ) -> None: ...
66
78
  def print_help(self, prog_name: str, subcommand: str) -> None: ...
67
- def run_from_argv(self, argv: list[str]) -> None: ...
79
+ def run_from_argv(self, argv: Sequence[str]) -> None: ...
68
80
  def execute(self, *args: Any, **options: Any) -> Any: ...
81
+ def get_check_kwargs(self, options: dict[str, Any]) -> dict[str, Any]: ...
69
82
  def check(
70
83
  self,
71
84
  app_configs: list[AppConfig] | None = ...,
@@ -73,15 +86,18 @@ class BaseCommand:
73
86
  display_num_errors: bool = ...,
74
87
  include_deployment_checks: bool = ...,
75
88
  fail_level: int = ...,
89
+ databases: list[str] | None = None,
76
90
  ) -> None: ...
77
91
  def check_migrations(self) -> None: ...
78
92
  def handle(self, *args: Any, **options: Any) -> str | None: ...
79
93
 
80
94
  class AppCommand(BaseCommand):
81
- missing_args_message: str = ...
82
- def handle_app_config(self, app_config: Any, **options: Any) -> None: ...
95
+ missing_args_message: str
96
+ def handle(self, *app_labels: str, **options: Any) -> str: ...
97
+ def handle_app_config(self, app_config: AppConfig, **options: Any) -> str: ...
83
98
 
84
99
  class LabelCommand(BaseCommand):
85
- label: str = ...
86
- missing_args_message: Any = ...
87
- def handle_label(self, label: Any, **options: Any) -> None: ...
100
+ label: str
101
+ missing_args_message: str
102
+ def handle(self, *labels: str, **options: Any) -> str: ...
103
+ def handle_label(self, label: str, **options: Any) -> str: ...
@@ -1,5 +1,5 @@
1
1
  import os
2
- from typing import Any
2
+ from typing import Any, TypeAlias
3
3
 
4
4
  from django.core.management.base import BaseCommand as BaseCommand
5
5
  from django.core.management.base import CommandError as CommandError
@@ -7,7 +7,7 @@ from django.core.management.base import CommandParser as CommandParser
7
7
  from django.core.management.utils import find_command as find_command
8
8
  from django.core.management.utils import popen_wrapper as popen_wrapper
9
9
 
10
- _PathType = str | bytes | os.PathLike[Any]
10
+ _PathType: TypeAlias = str | bytes | os.PathLike[Any]
11
11
 
12
12
  def has_bom(fn: _PathType) -> bool: ...
13
13
  def is_writable(path: _PathType) -> bool: ...
@@ -4,7 +4,7 @@ from typing import Any
4
4
  from wsgiref import simple_server
5
5
 
6
6
  from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
7
- from django.core.wsgi import get_wsgi_application as get_wsgi_application # noqa: F401
7
+ from django.core.wsgi import get_wsgi_application as get_wsgi_application
8
8
 
9
9
  class WSGIServer(simple_server.WSGIServer):
10
10
  request_queue_size: int = ...
@@ -1,14 +1,14 @@
1
1
  from collections.abc import Callable, Collection
2
2
  from decimal import Decimal
3
3
  from re import Pattern, RegexFlag
4
- from typing import Any
4
+ from typing import Any, TypeAlias
5
5
 
6
6
  from django.core.files.base import File
7
7
 
8
8
  EMPTY_VALUES: Any
9
9
 
10
- _Regex = str | Pattern[str]
11
- _ErrorMessage = str | Any
10
+ _Regex: TypeAlias = str | Pattern[str]
11
+ _ErrorMessage: TypeAlias = str | Any
12
12
 
13
13
  def _lazy_re_compile(regex: _Regex, flags: int = ...) -> Any: ...
14
14
 
@@ -71,7 +71,7 @@ def validate_ipv4_address(value: str) -> None: ...
71
71
  def validate_ipv6_address(value: str) -> None: ...
72
72
  def validate_ipv46_address(value: str) -> None: ...
73
73
 
74
- _IPValidator = tuple[Callable[[Any], None], str]
74
+ _IPValidator: TypeAlias = tuple[Callable[[Any], None], str]
75
75
  ip_address_validator_map: dict[str, _IPValidator]
76
76
 
77
77
  def ip_address_validators(protocol: str, unpack_ipv4: bool) -> _IPValidator: ...
@@ -1,7 +1,7 @@
1
1
  from collections.abc import Sequence
2
2
  from datetime import date, datetime, time, timedelta
3
3
  from decimal import Decimal
4
- from typing import Any
4
+ from typing import Any, TypeAlias
5
5
 
6
6
  from django.core.management.color import Style
7
7
  from django.db import DefaultConnectionProxy
@@ -12,7 +12,7 @@ from django.db.models.expressions import Case, Expression
12
12
  from django.db.models.fields import Field
13
13
  from django.db.models.sql.compiler import SQLCompiler
14
14
 
15
- _Connection = DefaultConnectionProxy | BaseDatabaseWrapper
15
+ _Connection: TypeAlias = DefaultConnectionProxy | BaseDatabaseWrapper
16
16
 
17
17
  class BaseDatabaseOperations:
18
18
  compiler_module: str = ...
@@ -1,5 +1,6 @@
1
1
  from collections.abc import Sequence
2
2
  from contextlib import AbstractContextManager
3
+ from types import TracebackType
3
4
  from typing import Any
4
5
 
5
6
  from django.db.backends.ddl_references import Statement
@@ -46,7 +47,12 @@ class BaseDatabaseSchemaEditor(AbstractContextManager[Any]):
46
47
  deferred_sql: Any = ...
47
48
  atomic: Any = ...
48
49
  def __enter__(self) -> BaseDatabaseSchemaEditor: ...
49
- def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: ...
50
+ def __exit__(
51
+ self,
52
+ exc_type: type[BaseException] | None,
53
+ exc_value: BaseException | None,
54
+ traceback: TracebackType | None,
55
+ ) -> None: ...
50
56
  def execute(
51
57
  self,
52
58
  sql: Statement | str,
@@ -2,7 +2,7 @@ import types
2
2
  from collections.abc import Iterable, Iterator, Mapping, Sequence
3
3
  from datetime import date, datetime, time
4
4
  from decimal import Decimal
5
- from typing import IO, Any, Literal
5
+ from typing import IO, Any, Literal, TypeAlias
6
6
  from uuid import UUID
7
7
 
8
8
  import psycopg2.extensions
@@ -12,8 +12,8 @@ from psycopg2.extensions import Column
12
12
  logger: Any
13
13
 
14
14
  # Python types that can be adapted to SQL.
15
- _Mixed = None | bool | int | float | Decimal | str | bytes | datetime | UUID
16
- _SQLType = _Mixed | Sequence[_Mixed] | Mapping[str, _Mixed]
15
+ _Mixed: TypeAlias = None | bool | int | float | Decimal | str | bytes | datetime | UUID
16
+ _SQLType: TypeAlias = _Mixed | Sequence[_Mixed] | Mapping[str, _Mixed]
17
17
 
18
18
  class CursorWrapper:
19
19
  cursor: psycopg2.extensions.cursor = ...
@@ -6,4 +6,4 @@ from .migration import Migration as Migration
6
6
  from .migration import swappable_dependency as swappable_dependency
7
7
 
8
8
  # FIXME: Add all operations here
9
- from .operations import * # noqa:F403
9
+ from .operations import *
@@ -1,8 +1,7 @@
1
- from typing_extensions import Self
2
-
3
1
  from django.db.backends.base.schema import BaseDatabaseSchemaEditor
4
2
  from django.db.migrations.operations.base import Operation
5
3
  from django.db.migrations.state import ProjectState
4
+ from typing_extensions import Self
6
5
 
7
6
  class Migration:
8
7
  operations: list[Operation] = ...
@@ -1,25 +1,50 @@
1
+ import enum
2
+ from collections.abc import Sequence
1
3
  from typing import Any
2
4
 
5
+ from django.db.backends.base.schema import BaseDatabaseSchemaEditor
6
+ from django.db.migrations.state import ProjectState
7
+ from django.db.models import Model
8
+ from typing_extensions import Self
9
+
10
+ class OperationCategory(str, enum.Enum):
11
+ ADDITION = "+"
12
+ REMOVAL = "-"
13
+ ALTERATION = "~"
14
+ PYTHON = "p"
15
+ SQL = "s"
16
+ MIXED = "?"
17
+
3
18
  class Operation:
4
- reversible: bool = ...
5
- reduces_to_sql: bool = ...
6
- atomic: bool = ...
7
- elidable: bool = ...
8
- serialization_expand_args: Any = ...
9
- def deconstruct(self) -> Any: ...
10
- def state_forwards(self, app_label: Any, state: Any) -> None: ...
19
+ reversible: bool
20
+ reduces_to_sql: bool
21
+ atomic: bool
22
+ elidable: bool
23
+ serialization_expand_args: list[Any]
24
+ category: OperationCategory | None
25
+ def __new__(cls, *args: Any, **kwargs: Any) -> Self: ...
26
+ def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
27
+ def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
11
28
  def database_forwards(
12
- self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
29
+ self,
30
+ app_label: str,
31
+ schema_editor: BaseDatabaseSchemaEditor,
32
+ from_state: ProjectState,
33
+ to_state: ProjectState,
13
34
  ) -> None: ...
14
35
  def database_backwards(
15
- self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
36
+ self,
37
+ app_label: str,
38
+ schema_editor: BaseDatabaseSchemaEditor,
39
+ from_state: ProjectState,
40
+ to_state: ProjectState,
16
41
  ) -> None: ...
17
42
  def describe(self) -> str: ...
18
- def references_model(self, name: str, app_label: str = ...) -> bool: ...
19
- def references_field(
20
- self, model_name: str, name: str, app_label: str = ...
21
- ) -> bool: ...
22
- def allow_migrate_model(self, connection_alias: Any, model: Any) -> bool: ...
43
+ def references_model(self, name: str, app_label: str) -> bool: ...
44
+ def references_field(self, model_name: str, name: str, app_label: str) -> bool: ...
45
+ def allow_migrate_model(
46
+ self, connection_alias: str, model: type[Model]
47
+ ) -> bool | None: ...
23
48
  def reduce(
24
- self, operation: Operation, in_between: list[Operation], app_label: str = ...
25
- ) -> bool: ...
49
+ self, operation: Operation, app_label: str
50
+ ) -> list[Operation] | bool: ...
@@ -6,5 +6,5 @@ def topological_sort_as_sets(
6
6
  dependency_graph: dict[Operation, set[Operation]]
7
7
  ) -> Iterator[set[Operation]]: ...
8
8
  def stable_topological_sort(
9
- l: list[Operation], dependency_graph: dict[Operation, set[Operation]] # noqa:E741
9
+ l: list[Operation], dependency_graph: dict[Operation, set[Operation]]
10
10
  ) -> list[Operation]: ...
@@ -8,6 +8,7 @@ from .aggregates import Count as Count
8
8
  from .aggregates import Max as Max
9
9
  from .aggregates import Min as Min
10
10
  from .aggregates import StdDev as StdDev
11
+ from .aggregates import StringAgg as StringAgg
11
12
  from .aggregates import Sum as Sum
12
13
  from .aggregates import Variance as Variance
13
14
  from .base import Model as Model
@@ -78,10 +79,12 @@ from .fields import TextField as TextField
78
79
  from .fields import TimeField as TimeField
79
80
  from .fields import URLField as URLField
80
81
  from .fields import UUIDField as UUIDField
82
+ from .fields.composite import CompositePrimaryKey as CompositePrimaryKey
81
83
  from .fields.files import FieldFile as FieldFile
82
84
  from .fields.files import FileDescriptor as FileDescriptor
83
85
  from .fields.files import FileField as FileField
84
86
  from .fields.files import ImageField as ImageField
87
+ from .fields.generated import GeneratedField as GeneratedField
85
88
  from .fields.json import JSONField as JSONField
86
89
  from .fields.proxy import OrderWrt as OrderWrt
87
90
  from .fields.related import ForeignKey as ForeignKey
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
 
3
- from django.db.models.expressions import Func
3
+ from django.db.models.expressions import Combinable, Func
4
4
 
5
5
  class Aggregate(Func):
6
6
  filter_template: str = ...
@@ -19,5 +19,9 @@ class Count(Aggregate): ...
19
19
  class Max(Aggregate): ...
20
20
  class Min(Aggregate): ...
21
21
  class StdDev(Aggregate): ...
22
+
23
+ class StringAgg(Aggregate):
24
+ def __init__(self, expression: Combinable | str, delimiter: Combinable | str, **extra: Any) -> None: ...
25
+
22
26
  class Sum(Aggregate): ...
23
27
  class Variance(Aggregate): ...
@@ -1,6 +1,5 @@
1
1
  from collections.abc import Callable, Collection, Iterable
2
2
  from typing import Any, ClassVar
3
- from typing_extensions import Self
4
3
 
5
4
  from django.core.checks.messages import CheckMessage
6
5
  from django.core.exceptions import (
@@ -10,6 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
10
9
  from django.db.models.manager import BaseManager
11
10
  from django.db.models.options import Options
12
11
  from django.db.models.query import QuerySet
12
+ from typing_extensions import Self
13
13
 
14
14
  class ModelStateFieldsCacheDescriptor: ...
15
15
 
@@ -1 +1,8 @@
1
- LOOKUP_SEP: str = ...
1
+ from enum import Enum
2
+ from typing import cast
3
+
4
+ LOOKUP_SEP: str
5
+
6
+ class OnConflict(Enum):
7
+ IGNORE = cast(str, ...)
8
+ UPDATE = cast(str, ...)
@@ -1,16 +1,17 @@
1
1
  from collections.abc import Sequence
2
2
  from enum import Enum
3
- from typing import Any
4
- from typing_extensions import Self
3
+ from typing import Any, cast, overload
4
+ from typing_extensions import Self, deprecated
5
5
 
6
6
  from django.db.backends.base.schema import BaseDatabaseSchemaEditor
7
7
  from django.db.models.base import Model
8
8
  from django.db.models.expressions import BaseExpression, Combinable
9
9
  from django.db.models.query_utils import Q
10
+ from typing_extensions import Self
10
11
 
11
12
  class Deferrable(Enum):
12
- DEFERRED: str
13
- IMMEDIATE: str
13
+ DEFERRED = cast(str, ...)
14
+ IMMEDIATE = cast(str, ...)
14
15
 
15
16
  class BaseConstraint:
16
17
  name: str
@@ -39,27 +40,65 @@ class BaseConstraint:
39
40
  def clone(self) -> Self: ...
40
41
 
41
42
  class CheckConstraint(BaseConstraint):
42
- check: Q
43
+ check: Q | BaseExpression
44
+ condition: Q | BaseExpression
45
+
46
+ @overload
47
+ @deprecated(
48
+ "check keyword argument is deprecated in favor of condition and will be removed in Django 6.0"
49
+ )
43
50
  def __init__(
44
51
  self,
45
52
  *,
46
- check: Q,
47
53
  name: str,
48
- violation_error_message: str | None = ...,
54
+ condition: None = None,
55
+ check: Q | BaseExpression,
56
+ violation_error_code: str | None = None,
57
+ violation_error_message: str | None = None,
58
+ ) -> None: ...
59
+ @overload
60
+ def __init__(
61
+ self,
62
+ *,
63
+ name: str,
64
+ condition: Q | BaseExpression,
65
+ check: None = None,
66
+ violation_error_code: str | None = None,
67
+ violation_error_message: str | None = None,
49
68
  ) -> None: ...
50
69
 
51
70
  class UniqueConstraint(BaseConstraint):
52
- fields: tuple[str]
71
+ expressions: Sequence[BaseExpression | Combinable]
72
+ fields: Sequence[str]
53
73
  condition: Q | None
74
+ deferrable: Deferrable | None
75
+ nulls_distinct: bool | None
76
+
77
+ @overload
54
78
  def __init__(
55
79
  self,
56
- *expressions: BaseExpression | Combinable | str,
57
- fields: Sequence[str] = ...,
58
- name: str | None = ...,
59
- condition: Q | None = ...,
60
- deferrable: Deferrable | None = ...,
61
- include: str | Sequence[str] | None = ...,
62
- opclasses: Sequence[str] = ...,
63
- violation_error_message: str | None = ...,
64
- nulls_distinct: bool | None = ...,
80
+ *expressions: str | BaseExpression | Combinable,
81
+ fields: None = None,
82
+ name: str | None = None,
83
+ condition: Q | None = None,
84
+ deferrable: Deferrable | None = None,
85
+ include: Sequence[str] | None = None,
86
+ opclasses: Sequence[Any] = (),
87
+ nulls_distinct: bool | None = None,
88
+ violation_error_code: str | None = None,
89
+ violation_error_message: str | None = None,
90
+ ) -> None: ...
91
+ @overload
92
+ def __init__(
93
+ self,
94
+ *,
95
+ fields: Sequence[str],
96
+ name: str | None = None,
97
+ condition: Q | None = None,
98
+ deferrable: Deferrable | None = None,
99
+ include: Sequence[str] | None = None,
100
+ opclasses: Sequence[Any] = (),
101
+ nulls_distinct: bool | None = None,
102
+ violation_error_code: str | None = None,
103
+ violation_error_message: str | None = None,
65
104
  ) -> None: ...
@@ -1,6 +1,6 @@
1
1
  import enum
2
2
  from collections.abc import Sequence
3
- from typing import Any, TypeVar
3
+ from typing import Any, TypeAlias, TypeVar
4
4
 
5
5
  _EnumMemberT = TypeVar("_EnumMemberT")
6
6
 
@@ -13,6 +13,8 @@ class ChoicesMeta(enum.EnumMeta):
13
13
  @property
14
14
  def choices(self: type[_EnumMemberT]) -> Sequence[tuple[_EnumMemberT, str]]: ...
15
15
 
16
+ ChoicesType: TypeAlias = ChoicesMeta
17
+
16
18
  class Choices(enum.Enum, metaclass=ChoicesMeta):
17
19
  def __str__(self) -> Any: ...
18
20
  @property
@@ -1,23 +1,23 @@
1
1
  from collections.abc import Callable, Iterable, Iterator, Sequence
2
2
  from datetime import datetime, timedelta
3
3
  from decimal import Decimal
4
- from typing import Any
5
- from typing_extensions import Self
4
+ from typing import Any, TypeAlias
6
5
 
7
6
  from django.db.models import Q, QuerySet
8
7
  from django.db.models.fields import Field
9
8
  from django.db.models.lookups import Lookup
10
9
  from django.db.models.query import _BaseQuerySet
11
10
  from django.db.models.sql.compiler import SQLCompiler
11
+ from typing_extensions import Self
12
12
 
13
- _OutputField = Field[Any, Any] | str
13
+ _OutputField: TypeAlias = Field[Any, Any] | str
14
14
 
15
15
  class SQLiteNumericMixin:
16
16
  def as_sqlite(
17
17
  self, compiler: SQLCompiler, connection: Any, **extra_context: Any
18
18
  ) -> tuple[str, list[float]]: ...
19
19
 
20
- _Numeric = float | Decimal
20
+ _Numeric: TypeAlias = float | Decimal
21
21
 
22
22
  class Combinable:
23
23
  ADD: str = ...
@@ -40,11 +40,11 @@ class Combinable:
40
40
  def __itruediv__(self, other: Combinable | _Numeric) -> Self: ...
41
41
  def __mod__(self, other: int | Combinable) -> Self: ...
42
42
  def __pow__(self, other: _Numeric | Combinable) -> Self: ...
43
- def __and__(self, other: Combinable) -> Self: ...
43
+ def __and__(self, other: Combinable | Q) -> Self: ...
44
44
  def bitand(self, other: int) -> Self: ...
45
45
  def bitleftshift(self, other: int) -> Self: ...
46
46
  def bitrightshift(self, other: int) -> Self: ...
47
- def __or__(self, other: Combinable) -> Self: ...
47
+ def __or__(self, other: Combinable | Q) -> Self: ...
48
48
  def bitor(self, other: int) -> Self: ...
49
49
  def __radd__(
50
50
  self, other: datetime | _Numeric | Combinable | None
@@ -99,7 +99,7 @@ class BaseExpression:
99
99
  def as_sqlite(self, compiler: SQLCompiler, connection: Any) -> Any: ...
100
100
  def as_sql(
101
101
  self, compiler: SQLCompiler, connection: Any, **extra_context: Any
102
- ) -> Any: ...
102
+ ) -> tuple[str, list[Any] | tuple[Any]]: ...
103
103
  def as_mysql(self, compiler: Any, connection: Any) -> Any: ...
104
104
  def as_postgresql(self, compiler: Any, connection: Any) -> Any: ...
105
105
  def as_oracle(self, compiler: Any, connection: Any) -> Any: ...