django-types 0.22.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.
- django-stubs/apps/config.pyi +3 -2
- django-stubs/conf/global_settings.pyi +9 -9
- django-stubs/conf/urls/__init__.pyi +2 -2
- django-stubs/contrib/admin/checks.pyi +2 -2
- django-stubs/contrib/admin/models.pyi +4 -4
- django-stubs/contrib/admin/options.pyi +21 -13
- django-stubs/contrib/admin/utils.pyi +1 -2
- django-stubs/contrib/admin/views/main.pyi +1 -1
- django-stubs/contrib/auth/backends.pyi +2 -2
- django-stubs/contrib/auth/decorators.pyi +1 -1
- django-stubs/contrib/auth/management/commands/createsuperuser.pyi +1 -1
- django-stubs/contrib/auth/models.pyi +3 -3
- django-stubs/contrib/contenttypes/fields.pyi +1 -1
- django-stubs/contrib/gis/db/models/__init__.pyi +2 -2
- django-stubs/contrib/gis/gdal/srs.pyi +4 -4
- django-stubs/contrib/gis/geos/geometry.pyi +1 -1
- django-stubs/contrib/gis/geos/io.pyi +1 -1
- django-stubs/contrib/postgres/fields/array.pyi +1 -1
- django-stubs/contrib/postgres/fields/citext.pyi +9 -9
- django-stubs/contrib/postgres/fields/hstore.pyi +7 -7
- django-stubs/contrib/postgres/fields/ranges.pyi +6 -6
- django-stubs/contrib/postgres/search.pyi +3 -3
- django-stubs/contrib/sessions/base_session.pyi +1 -1
- django-stubs/contrib/sessions/models.pyi +1 -1
- django-stubs/contrib/sites/models.pyi +1 -1
- django-stubs/core/checks/registry.pyi +2 -2
- django-stubs/core/exceptions.pyi +2 -2
- django-stubs/core/files/base.pyi +1 -1
- django-stubs/core/handlers/wsgi.pyi +3 -3
- django-stubs/core/mail/__init__.pyi +2 -1
- django-stubs/core/mail/backends/base.pyi +1 -1
- django-stubs/core/mail/message.pyi +7 -7
- django-stubs/core/management/__init__.pyi +10 -8
- django-stubs/core/management/base.pyi +49 -33
- django-stubs/core/management/commands/compilemessages.pyi +2 -2
- django-stubs/core/servers/basehttp.pyi +1 -1
- django-stubs/core/validators.pyi +4 -4
- django-stubs/db/backends/base/operations.pyi +2 -2
- django-stubs/db/backends/base/schema.pyi +7 -1
- django-stubs/db/backends/utils.pyi +3 -3
- django-stubs/db/migrations/__init__.pyi +1 -1
- django-stubs/db/migrations/migration.pyi +1 -2
- django-stubs/db/migrations/operations/base.pyi +1 -1
- django-stubs/db/migrations/topological_sort.pyi +1 -1
- django-stubs/db/models/__init__.pyi +3 -1
- django-stubs/db/models/aggregates.pyi +5 -1
- django-stubs/db/models/base.pyi +1 -1
- django-stubs/db/models/constants.pyi +8 -1
- django-stubs/db/models/constraints.pyi +56 -17
- django-stubs/db/models/enums.pyi +3 -1
- django-stubs/db/models/expressions.pyi +7 -7
- django-stubs/db/models/fields/__init__.pyi +28 -25
- django-stubs/db/models/fields/composite.pyi +2 -3
- django-stubs/db/models/fields/files.pyi +3 -1
- django-stubs/db/models/fields/generated.pyi +84 -0
- django-stubs/db/models/fields/json.pyi +3 -1
- django-stubs/db/models/fields/related.pyi +26 -21
- django-stubs/db/models/indexes.pyi +1 -1
- django-stubs/db/models/lookups.pyi +1 -1
- django-stubs/db/models/manager.pyi +1 -1
- django-stubs/db/models/options.pyi +1 -0
- django-stubs/db/models/query.pyi +6 -6
- django-stubs/db/utils.pyi +1 -2
- django-stubs/dispatch/dispatcher.pyi +33 -26
- django-stubs/forms/fields.pyi +4 -4
- django-stubs/forms/models.pyi +4 -4
- django-stubs/forms/renderers.pyi +1 -1
- django-stubs/forms/widgets.pyi +2 -2
- django-stubs/http/request.pyi +4 -3
- django-stubs/http/response.pyi +9 -3
- django-stubs/shortcuts.pyi +17 -32
- django-stubs/template/backends/django.pyi +1 -1
- django-stubs/template/backends/dummy.pyi +1 -1
- django-stubs/template/backends/jinja2.pyi +1 -1
- django-stubs/template/base.pyi +5 -5
- django-stubs/template/context.pyi +9 -3
- django-stubs/template/defaultfilters.pyi +1 -1
- django-stubs/template/engine.pyi +2 -2
- django-stubs/template/library.pyi +1 -1
- django-stubs/template/loader.pyi +2 -4
- django-stubs/template/response.pyi +2 -2
- django-stubs/template/smartif.pyi +2 -2
- django-stubs/test/client.pyi +3 -3
- django-stubs/test/html.pyi +2 -2
- django-stubs/test/signals.pyi +1 -1
- django-stubs/test/testcases.pyi +10 -4
- django-stubs/test/utils.pyi +12 -7
- django-stubs/urls/conf.pyi +2 -2
- django-stubs/utils/archive.pyi +7 -1
- django-stubs/utils/datastructures.pyi +1 -0
- django-stubs/utils/dateformat.pyi +3 -3
- django-stubs/utils/deprecation.pyi +2 -2
- django-stubs/utils/functional.pyi +64 -31
- django-stubs/utils/safestring.pyi +1 -0
- django-stubs/utils/six.pyi +4 -5
- django-stubs/utils/timezone.pyi +7 -7
- django-stubs/utils/topological_sort.pyi +1 -1
- django-stubs/utils/translation/__init__.pyi +15 -6
- django-stubs/utils/tree.pyi +2 -2
- django-stubs/utils/xmlutils.pyi +2 -1
- django-stubs/views/__init__.pyi +2 -0
- django-stubs/views/csrf.pyi +4 -4
- django-stubs/views/debug.pyi +49 -50
- django-stubs/views/decorators/cache.pyi +1 -1
- django-stubs/views/decorators/debug.pyi +3 -1
- django-stubs/views/defaults.pyi +3 -6
- django-stubs/views/generic/dates.pyi +4 -2
- django-stubs/views/i18n.pyi +7 -16
- django-stubs/views/static.pyi +6 -7
- {django_types-0.22.0.dist-info → django_types-0.23.0.dist-info}/METADATA +8 -15
- {django_types-0.22.0.dist-info → django_types-0.23.0.dist-info}/RECORD +186 -185
- {django_types-0.22.0.dist-info → django_types-0.23.0.dist-info}/WHEEL +1 -1
- {django_types-0.22.0.dist-info → django_types-0.23.0.dist-info/licenses}/LICENSE.txt +0 -0
|
@@ -3,26 +3,26 @@ import ipaddress
|
|
|
3
3
|
import uuid
|
|
4
4
|
from collections.abc import Callable, Iterable, Mapping, Sequence
|
|
5
5
|
from datetime import date, datetime, time, timedelta
|
|
6
|
-
from typing import Any, Generic, Literal, TypeVar, overload
|
|
7
|
-
from typing_extensions import Self
|
|
6
|
+
from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload
|
|
8
7
|
|
|
9
8
|
from django.core.checks import CheckMessage
|
|
10
9
|
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
|
11
|
-
from django.db.models import Model, TextChoices
|
|
10
|
+
from django.db.models import IntegerChoices, Model, TextChoices
|
|
12
11
|
from django.db.models.expressions import Col, Combinable, Func
|
|
13
12
|
from django.db.models.query_utils import RegisterLookupMixin
|
|
14
13
|
from django.forms import Widget
|
|
14
|
+
from typing_extensions import Self
|
|
15
15
|
|
|
16
16
|
BLANK_CHOICE_DASH: list[tuple[str, str]] = ...
|
|
17
17
|
|
|
18
|
-
_Choice = tuple[Any, str]
|
|
19
|
-
_ChoiceNamedGroup = tuple[str, Iterable[_Choice]]
|
|
20
|
-
_ChoicesMapping = Mapping[Any, str | Mapping[Any, str]]
|
|
21
|
-
_LiteralFieldChoices = Iterable[_Choice | _ChoiceNamedGroup] | _ChoicesMapping
|
|
22
|
-
_FieldChoices = _LiteralFieldChoices | Callable[[], _LiteralFieldChoices]
|
|
18
|
+
_Choice: TypeAlias = tuple[Any, str]
|
|
19
|
+
_ChoiceNamedGroup: TypeAlias = tuple[str, Iterable[_Choice]]
|
|
20
|
+
_ChoicesMapping: TypeAlias = Mapping[Any, str | Mapping[Any, str]]
|
|
21
|
+
_LiteralFieldChoices: TypeAlias = Iterable[_Choice | _ChoiceNamedGroup] | _ChoicesMapping
|
|
22
|
+
_FieldChoices: TypeAlias = _LiteralFieldChoices | Callable[[], _LiteralFieldChoices]
|
|
23
23
|
|
|
24
|
-
_ValidatorCallable = Callable[..., None]
|
|
25
|
-
_ErrorMessagesToOverride = dict[str, Any]
|
|
24
|
+
_ValidatorCallable: TypeAlias = Callable[..., None]
|
|
25
|
+
_ErrorMessagesToOverride: TypeAlias = dict[str, Any]
|
|
26
26
|
|
|
27
27
|
# __set__ value type
|
|
28
28
|
_ST = TypeVar("_ST")
|
|
@@ -40,6 +40,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
|
|
40
40
|
primary_key: bool
|
|
41
41
|
remote_field: Field[_ST, _GT]
|
|
42
42
|
is_relation: bool
|
|
43
|
+
hidden: bool
|
|
43
44
|
related_model: Any | None = ...
|
|
44
45
|
one_to_many: bool | None = ...
|
|
45
46
|
one_to_one: bool | None = ...
|
|
@@ -134,7 +135,7 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]):
|
|
|
134
135
|
unique_for_date: str | None = ...,
|
|
135
136
|
unique_for_month: str | None = ...,
|
|
136
137
|
unique_for_year: str | None = ...,
|
|
137
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
138
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
138
139
|
help_text: str = ...,
|
|
139
140
|
db_column: str | None = ...,
|
|
140
141
|
db_comment: str | None = ...,
|
|
@@ -162,7 +163,7 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]):
|
|
|
162
163
|
unique_for_date: str | None = ...,
|
|
163
164
|
unique_for_month: str | None = ...,
|
|
164
165
|
unique_for_year: str | None = ...,
|
|
165
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
166
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
166
167
|
help_text: str = ...,
|
|
167
168
|
db_column: str | None = ...,
|
|
168
169
|
db_comment: str | None = ...,
|
|
@@ -195,7 +196,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]):
|
|
|
195
196
|
unique_for_date: str | None = ...,
|
|
196
197
|
unique_for_month: str | None = ...,
|
|
197
198
|
unique_for_year: str | None = ...,
|
|
198
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
199
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
199
200
|
help_text: str = ...,
|
|
200
201
|
db_column: str | None = ...,
|
|
201
202
|
db_comment: str | None = ...,
|
|
@@ -223,7 +224,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]):
|
|
|
223
224
|
unique_for_date: str | None = ...,
|
|
224
225
|
unique_for_month: str | None = ...,
|
|
225
226
|
unique_for_year: str | None = ...,
|
|
226
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
227
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
227
228
|
help_text: str = ...,
|
|
228
229
|
db_column: str | None = ...,
|
|
229
230
|
db_comment: str | None = ...,
|
|
@@ -253,9 +254,10 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I])
|
|
|
253
254
|
unique_for_date: str | None = ...,
|
|
254
255
|
unique_for_month: str | None = ...,
|
|
255
256
|
unique_for_year: str | None = ...,
|
|
256
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
257
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
257
258
|
help_text: str = ...,
|
|
258
259
|
db_column: str | None = ...,
|
|
260
|
+
db_comment: str | None = ...,
|
|
259
261
|
db_tablespace: str | None = ...,
|
|
260
262
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
261
263
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -280,7 +282,7 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I])
|
|
|
280
282
|
unique_for_date: str | None = ...,
|
|
281
283
|
unique_for_month: str | None = ...,
|
|
282
284
|
unique_for_year: str | None = ...,
|
|
283
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
285
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices]= ...,
|
|
284
286
|
help_text: str = ...,
|
|
285
287
|
db_column: str | None = ...,
|
|
286
288
|
db_comment: str | None = ...,
|
|
@@ -310,7 +312,7 @@ class SmallIntegerField(IntegerField[_I]):
|
|
|
310
312
|
unique_for_date: str | None = ...,
|
|
311
313
|
unique_for_month: str | None = ...,
|
|
312
314
|
unique_for_year: str | None = ...,
|
|
313
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
315
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices]= ...,
|
|
314
316
|
help_text: str = ...,
|
|
315
317
|
db_column: str | None = ...,
|
|
316
318
|
db_comment: str | None = ...,
|
|
@@ -338,7 +340,7 @@ class SmallIntegerField(IntegerField[_I]):
|
|
|
338
340
|
unique_for_date: str | None = ...,
|
|
339
341
|
unique_for_month: str | None = ...,
|
|
340
342
|
unique_for_year: str | None = ...,
|
|
341
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
343
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices]= ...,
|
|
342
344
|
help_text: str = ...,
|
|
343
345
|
db_column: str | None = ...,
|
|
344
346
|
db_comment: str | None = ...,
|
|
@@ -368,7 +370,7 @@ class BigIntegerField(IntegerField[_I]):
|
|
|
368
370
|
unique_for_date: str | None = ...,
|
|
369
371
|
unique_for_month: str | None = ...,
|
|
370
372
|
unique_for_year: str | None = ...,
|
|
371
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
373
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
372
374
|
help_text: str = ...,
|
|
373
375
|
db_column: str | None = ...,
|
|
374
376
|
db_comment: str | None = ...,
|
|
@@ -396,7 +398,7 @@ class BigIntegerField(IntegerField[_I]):
|
|
|
396
398
|
unique_for_date: str | None = ...,
|
|
397
399
|
unique_for_month: str | None = ...,
|
|
398
400
|
unique_for_year: str | None = ...,
|
|
399
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
401
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
400
402
|
help_text: str = ...,
|
|
401
403
|
db_column: str | None = ...,
|
|
402
404
|
db_comment: str | None = ...,
|
|
@@ -426,7 +428,7 @@ class PositiveBigIntegerField(IntegerField[_I]):
|
|
|
426
428
|
unique_for_date: str | None = ...,
|
|
427
429
|
unique_for_month: str | None = ...,
|
|
428
430
|
unique_for_year: str | None = ...,
|
|
429
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
431
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
430
432
|
help_text: str = ...,
|
|
431
433
|
db_column: str | None = ...,
|
|
432
434
|
db_comment: str | None = ...,
|
|
@@ -454,7 +456,7 @@ class PositiveBigIntegerField(IntegerField[_I]):
|
|
|
454
456
|
unique_for_date: str | None = ...,
|
|
455
457
|
unique_for_month: str | None = ...,
|
|
456
458
|
unique_for_year: str | None = ...,
|
|
457
|
-
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
|
|
459
|
+
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] | type[IntegerChoices] = ...,
|
|
458
460
|
help_text: str = ...,
|
|
459
461
|
db_column: str | None = ...,
|
|
460
462
|
db_comment: str | None = ...,
|
|
@@ -620,7 +622,7 @@ class AutoField(AutoFieldMixin, IntegerField[int], metaclass=AutoFieldMeta):
|
|
|
620
622
|
unique_for_year: str | None = ...,
|
|
621
623
|
choices: Iterable[
|
|
622
624
|
tuple[int, str] | tuple[str, Iterable[tuple[int, str]]]
|
|
623
|
-
] = ...,
|
|
625
|
+
] | type[IntegerChoices] = ...,
|
|
624
626
|
help_text: str = ...,
|
|
625
627
|
db_column: str | None = ...,
|
|
626
628
|
db_comment: str | None = ...,
|
|
@@ -652,7 +654,7 @@ class BigAutoField(AutoFieldMixin, BigIntegerField[int]):
|
|
|
652
654
|
unique_for_year: str | None = ...,
|
|
653
655
|
choices: Iterable[
|
|
654
656
|
tuple[int, str] | tuple[str, Iterable[tuple[int, str]]]
|
|
655
|
-
] = ...,
|
|
657
|
+
] | type[IntegerChoices] = ...,
|
|
656
658
|
help_text: str = ...,
|
|
657
659
|
db_column: str | None = ...,
|
|
658
660
|
db_comment: str | None = ...,
|
|
@@ -684,7 +686,7 @@ class SmallAutoField(AutoFieldMixin, SmallIntegerField[int]):
|
|
|
684
686
|
unique_for_year: str | None = ...,
|
|
685
687
|
choices: Iterable[
|
|
686
688
|
tuple[int, str] | tuple[str, Iterable[tuple[int, str]]]
|
|
687
|
-
] = ...,
|
|
689
|
+
] | type[IntegerChoices] = ...,
|
|
688
690
|
help_text: str = ...,
|
|
689
691
|
db_column: str | None = ...,
|
|
690
692
|
db_comment: str | None = ...,
|
|
@@ -1055,6 +1057,7 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]):
|
|
|
1055
1057
|
choices: Iterable[tuple[_B, str] | tuple[str, Iterable[tuple[_B, str]]]] = ...,
|
|
1056
1058
|
help_text: str = ...,
|
|
1057
1059
|
db_column: str | None = ...,
|
|
1060
|
+
db_comment: str | None = ...,
|
|
1058
1061
|
db_tablespace: str | None = ...,
|
|
1059
1062
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
1060
1063
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -2,14 +2,13 @@ from collections.abc import Iterable, Iterator, Mapping
|
|
|
2
2
|
from typing import Any, Literal
|
|
3
3
|
|
|
4
4
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
|
5
|
-
|
|
6
|
-
from django.db.models.fields import NOT_PROVIDED, Field
|
|
7
5
|
from django.db.models.base import Model
|
|
6
|
+
from django.db.models.fields import NOT_PROVIDED, Field
|
|
8
7
|
from django.db.models.fields.reverse_related import ForeignObjectRel
|
|
9
8
|
from django.utils.functional import cached_property
|
|
10
9
|
|
|
11
10
|
StrOrPromise = str
|
|
12
|
-
from django.db.models.fields import
|
|
11
|
+
from django.db.models.fields import _LiteralFieldChoices, _ValidatorCallable
|
|
13
12
|
|
|
14
13
|
class AttributeSetter:
|
|
15
14
|
def __init__(self, name: str, value: Any) -> None: ...
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from collections.abc import Callable, Iterable
|
|
2
2
|
from typing import Any, overload
|
|
3
|
-
from typing_extensions import Self
|
|
4
3
|
|
|
5
4
|
from django.core.files.base import File
|
|
6
5
|
from django.core.files.images import ImageFile
|
|
@@ -12,6 +11,7 @@ from django.db.models.fields import (
|
|
|
12
11
|
_ErrorMessagesToOverride,
|
|
13
12
|
_ValidatorCallable,
|
|
14
13
|
)
|
|
14
|
+
from typing_extensions import Self
|
|
15
15
|
|
|
16
16
|
class FieldFile(File):
|
|
17
17
|
instance: Model = ...
|
|
@@ -65,6 +65,7 @@ class FileField(Field[FileDescriptor, FileDescriptor]):
|
|
|
65
65
|
] = ...,
|
|
66
66
|
help_text: str = ...,
|
|
67
67
|
db_column: str | None = ...,
|
|
68
|
+
db_comment: str | None = ...,
|
|
68
69
|
db_tablespace: str | None = ...,
|
|
69
70
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
70
71
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -115,6 +116,7 @@ class ImageField(FileField):
|
|
|
115
116
|
] = ...,
|
|
116
117
|
help_text: str = ...,
|
|
117
118
|
db_column: str | None = ...,
|
|
119
|
+
db_comment: str | None = ...,
|
|
118
120
|
db_tablespace: str | None = ...,
|
|
119
121
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
120
122
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from typing import Any, Literal, TypeVar, overload
|
|
3
|
+
|
|
4
|
+
from django.db.models import Combinable, Expression, ForeignObjectRel
|
|
5
|
+
from django.db.models.expressions import Col
|
|
6
|
+
from typing_extensions import Never
|
|
7
|
+
|
|
8
|
+
from . import Field, _ErrorMessagesToOverride, _ValidatorCallable
|
|
9
|
+
from .mixins import CheckFieldDefaultMixin
|
|
10
|
+
|
|
11
|
+
_GT = TypeVar("_GT", bound=Any | None)
|
|
12
|
+
|
|
13
|
+
class GeneratedField(CheckFieldDefaultMixin, Field[Never, _GT]):
|
|
14
|
+
generated: Literal[True]
|
|
15
|
+
db_returning: Literal[True]
|
|
16
|
+
expression: Combinable | Expression
|
|
17
|
+
|
|
18
|
+
@overload
|
|
19
|
+
def __new__(
|
|
20
|
+
cls,
|
|
21
|
+
*,
|
|
22
|
+
expression: Combinable | Expression,
|
|
23
|
+
output_field: Field[Any, _GT],
|
|
24
|
+
db_persist: bool,
|
|
25
|
+
#
|
|
26
|
+
verbose_name: str | None = ...,
|
|
27
|
+
name: str | None = ...,
|
|
28
|
+
primary_key: bool = ...,
|
|
29
|
+
max_length: int | None = ...,
|
|
30
|
+
unique: bool = ...,
|
|
31
|
+
blank: Literal[True] = ...,
|
|
32
|
+
null: Literal[False] = False,
|
|
33
|
+
db_index: bool = ...,
|
|
34
|
+
rel: ForeignObjectRel | None = ...,
|
|
35
|
+
editable: Literal[False] = ...,
|
|
36
|
+
serialize: bool = ...,
|
|
37
|
+
unique_for_date: str | None = ...,
|
|
38
|
+
unique_for_month: str | None = ...,
|
|
39
|
+
unique_for_year: str | None = ...,
|
|
40
|
+
choices: Iterable[tuple[Any, str] | tuple[str, Iterable[tuple[Any, str]]]] = ...,
|
|
41
|
+
help_text: str = ...,
|
|
42
|
+
db_column: str | None = ...,
|
|
43
|
+
db_tablespace: str | None = ...,
|
|
44
|
+
auto_created: bool = ...,
|
|
45
|
+
validators: Iterable[_ValidatorCallable] = ...,
|
|
46
|
+
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
47
|
+
db_comment: str | None = ...,
|
|
48
|
+
) -> GeneratedField[_GT]: ...
|
|
49
|
+
@overload
|
|
50
|
+
def __new__(
|
|
51
|
+
cls,
|
|
52
|
+
*,
|
|
53
|
+
expression: Combinable | Expression,
|
|
54
|
+
output_field: Field[Any, _GT],
|
|
55
|
+
db_persist: bool,
|
|
56
|
+
#
|
|
57
|
+
verbose_name: str | None = ...,
|
|
58
|
+
name: str | None = ...,
|
|
59
|
+
primary_key: bool = ...,
|
|
60
|
+
max_length: int | None = ...,
|
|
61
|
+
unique: bool = ...,
|
|
62
|
+
blank: Literal[True] = ...,
|
|
63
|
+
null: Literal[True],
|
|
64
|
+
db_index: bool = ...,
|
|
65
|
+
rel: ForeignObjectRel | None = ...,
|
|
66
|
+
editable: Literal[False] = ...,
|
|
67
|
+
serialize: bool = ...,
|
|
68
|
+
unique_for_date: str | None = ...,
|
|
69
|
+
unique_for_month: str | None = ...,
|
|
70
|
+
unique_for_year: str | None = ...,
|
|
71
|
+
choices: Iterable[tuple[Any, str] | tuple[str, Iterable[tuple[Any, str]]]] = ...,
|
|
72
|
+
help_text: str = ...,
|
|
73
|
+
db_column: str | None = ...,
|
|
74
|
+
db_tablespace: str | None = ...,
|
|
75
|
+
auto_created: bool = ...,
|
|
76
|
+
validators: Iterable[_ValidatorCallable] = ...,
|
|
77
|
+
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
78
|
+
db_comment: str | None = ...,
|
|
79
|
+
) -> GeneratedField[_GT | None]: ...
|
|
80
|
+
@property
|
|
81
|
+
def cached_col(self) -> Col: ...
|
|
82
|
+
def generated_sql(self, connection: Any) -> tuple[str, list[Any]]: ...
|
|
83
|
+
|
|
84
|
+
__all__ = ["GeneratedField"]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from collections.abc import Callable, Iterable
|
|
3
3
|
from typing import Any, Literal, TypeVar, overload
|
|
4
|
-
from typing_extensions import Self
|
|
5
4
|
|
|
6
5
|
from django.db.models import lookups
|
|
7
6
|
from django.db.models.expressions import Combinable
|
|
8
7
|
from django.db.models.lookups import PostgresOperatorLookup, Transform
|
|
8
|
+
from typing_extensions import Self
|
|
9
9
|
|
|
10
10
|
from . import Field, _ErrorMessagesToOverride, _ValidatorCallable
|
|
11
11
|
from .mixins import CheckFieldDefaultMixin
|
|
@@ -45,6 +45,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]):
|
|
|
45
45
|
] = ...,
|
|
46
46
|
help_text: str = ...,
|
|
47
47
|
db_column: str | None = ...,
|
|
48
|
+
db_comment: str | None = ...,
|
|
48
49
|
db_tablespace: str | None = ...,
|
|
49
50
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
50
51
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -75,6 +76,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]):
|
|
|
75
76
|
] = ...,
|
|
76
77
|
help_text: str = ...,
|
|
77
78
|
db_column: str | None = ...,
|
|
79
|
+
db_comment: str | None = ...,
|
|
78
80
|
db_tablespace: str | None = ...,
|
|
79
81
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
80
82
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from collections.abc import Callable, Iterable, Sequence
|
|
2
|
-
from typing import Any, Generic, Literal, Protocol, TypeVar, overload
|
|
3
|
-
from typing_extensions import Self
|
|
2
|
+
from typing import Any, Generic, Literal, Protocol, TypeAlias, TypeVar, overload
|
|
4
3
|
from uuid import UUID
|
|
5
4
|
|
|
6
5
|
from django.db import models
|
|
@@ -11,7 +10,7 @@ from django.db.models.fields.mixins import FieldCacheMixin
|
|
|
11
10
|
from django.db.models.fields.related_descriptors import (
|
|
12
11
|
ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
|
|
13
12
|
)
|
|
14
|
-
from django.db.models.fields.related_descriptors import (
|
|
13
|
+
from django.db.models.fields.related_descriptors import (
|
|
15
14
|
ForwardOneToOneDescriptor as ForwardOneToOneDescriptor,
|
|
16
15
|
)
|
|
17
16
|
from django.db.models.fields.related_descriptors import (
|
|
@@ -23,14 +22,13 @@ from django.db.models.fields.related_descriptors import (
|
|
|
23
22
|
from django.db.models.fields.related_descriptors import (
|
|
24
23
|
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor,
|
|
25
24
|
)
|
|
26
|
-
from django.db.models.fields.reverse_related import
|
|
27
|
-
ForeignObjectRel as ForeignObjectRel,
|
|
28
|
-
)
|
|
25
|
+
from django.db.models.fields.reverse_related import ForeignObjectRel as ForeignObjectRel
|
|
29
26
|
from django.db.models.fields.reverse_related import ManyToManyRel as ManyToManyRel
|
|
30
27
|
from django.db.models.fields.reverse_related import ManyToOneRel as ManyToOneRel
|
|
31
28
|
from django.db.models.fields.reverse_related import OneToOneRel as OneToOneRel
|
|
32
29
|
from django.db.models.manager import ManyToManyRelatedManager
|
|
33
30
|
from django.db.models.query_utils import PathInfo, Q
|
|
31
|
+
from typing_extensions import Self
|
|
34
32
|
|
|
35
33
|
class _DeleteProtocol(Protocol):
|
|
36
34
|
def __call__(
|
|
@@ -42,14 +40,14 @@ class _DeleteProtocol(Protocol):
|
|
|
42
40
|
) -> None: ...
|
|
43
41
|
|
|
44
42
|
_F = TypeVar("_F", bound=models.Field[Any, Any])
|
|
45
|
-
_Choice = tuple[Any, str]
|
|
46
|
-
_ChoiceNamedGroup = tuple[str, Iterable[_Choice]]
|
|
47
|
-
_FieldChoices = Iterable[_Choice | _ChoiceNamedGroup]
|
|
48
|
-
_ChoicesLimit = dict[str, Any] | Q | Callable[[], Q]
|
|
49
|
-
_OnDeleteOptions = _DeleteProtocol | Callable[[Any], _DeleteProtocol]
|
|
43
|
+
_Choice: TypeAlias = tuple[Any, str]
|
|
44
|
+
_ChoiceNamedGroup: TypeAlias = tuple[str, Iterable[_Choice]]
|
|
45
|
+
_FieldChoices: TypeAlias = Iterable[_Choice | _ChoiceNamedGroup]
|
|
46
|
+
_ChoicesLimit: TypeAlias = dict[str, Any] | Q | Callable[[], Q]
|
|
47
|
+
_OnDeleteOptions: TypeAlias = _DeleteProtocol | Callable[[Any], _DeleteProtocol]
|
|
50
48
|
|
|
51
|
-
_ValidatorCallable = Callable[..., None]
|
|
52
|
-
_ErrorMessagesToOverride = dict[str, Any]
|
|
49
|
+
_ValidatorCallable: TypeAlias = Callable[..., None]
|
|
50
|
+
_ErrorMessagesToOverride: TypeAlias = dict[str, Any]
|
|
53
51
|
|
|
54
52
|
RECURSIVE_RELATIONSHIP_CONSTANT: str = ...
|
|
55
53
|
|
|
@@ -110,7 +108,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]):
|
|
|
110
108
|
blank: bool = ...,
|
|
111
109
|
null: Literal[False] = False,
|
|
112
110
|
db_index: bool = ...,
|
|
113
|
-
default: _M | Callable[[], _M]
|
|
111
|
+
default: _M | Callable[[], _M] = ...,
|
|
114
112
|
editable: bool = ...,
|
|
115
113
|
auto_created: bool = ...,
|
|
116
114
|
serialize: bool = ...,
|
|
@@ -120,6 +118,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]):
|
|
|
120
118
|
choices: Iterable[tuple[_M, str] | tuple[str, Iterable[tuple[_M, str]]]] = ...,
|
|
121
119
|
help_text: str = ...,
|
|
122
120
|
db_column: str | None = ...,
|
|
121
|
+
db_comment: str | None = ...,
|
|
123
122
|
db_tablespace: str | None = ...,
|
|
124
123
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
125
124
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -147,7 +146,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]):
|
|
|
147
146
|
blank: bool = ...,
|
|
148
147
|
null: Literal[True],
|
|
149
148
|
db_index: bool = ...,
|
|
150
|
-
default: _M | Callable[[], _M] = ...,
|
|
149
|
+
default: _M | Callable[[], _M | None] | None = ...,
|
|
151
150
|
editable: bool = ...,
|
|
152
151
|
auto_created: bool = ...,
|
|
153
152
|
serialize: bool = ...,
|
|
@@ -157,6 +156,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]):
|
|
|
157
156
|
choices: Iterable[tuple[_M, str] | tuple[str, Iterable[tuple[_M, str]]]] = ...,
|
|
158
157
|
help_text: str = ...,
|
|
159
158
|
db_column: str | None = ...,
|
|
159
|
+
db_comment: str | None = ...,
|
|
160
160
|
db_tablespace: str | None = ...,
|
|
161
161
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
162
162
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -189,7 +189,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]):
|
|
|
189
189
|
blank: bool = ...,
|
|
190
190
|
null: Literal[False] = False,
|
|
191
191
|
db_index: bool = ...,
|
|
192
|
-
default: _M | Callable[[], _M]
|
|
192
|
+
default: _M | Callable[[], _M] = ...,
|
|
193
193
|
editable: bool = ...,
|
|
194
194
|
auto_created: bool = ...,
|
|
195
195
|
serialize: bool = ...,
|
|
@@ -199,6 +199,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]):
|
|
|
199
199
|
choices: Iterable[tuple[_M, str] | tuple[str, Iterable[tuple[_M, str]]]] = ...,
|
|
200
200
|
help_text: str = ...,
|
|
201
201
|
db_column: str | None = ...,
|
|
202
|
+
db_comment: str | None = ...,
|
|
202
203
|
db_tablespace: str | None = ...,
|
|
203
204
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
204
205
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -224,7 +225,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]):
|
|
|
224
225
|
blank: bool = ...,
|
|
225
226
|
null: Literal[True],
|
|
226
227
|
db_index: bool = ...,
|
|
227
|
-
default: _M | Callable[[], _M] = ...,
|
|
228
|
+
default: _M | Callable[[], _M | None] | None = ...,
|
|
228
229
|
editable: bool = ...,
|
|
229
230
|
auto_created: bool = ...,
|
|
230
231
|
serialize: bool = ...,
|
|
@@ -234,12 +235,13 @@ class ForeignKey(Generic[_M], ForeignObject[_M]):
|
|
|
234
235
|
choices: Iterable[tuple[_M, str] | tuple[str, Iterable[tuple[_M, str]]]] = ...,
|
|
235
236
|
help_text: str = ...,
|
|
236
237
|
db_column: str | None = ...,
|
|
238
|
+
db_comment: str | None = ...,
|
|
237
239
|
db_tablespace: str | None = ...,
|
|
238
240
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
239
241
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
240
242
|
) -> ForeignKey[_M | None]: ...
|
|
241
243
|
# class access
|
|
242
|
-
@overload
|
|
244
|
+
@overload # type: ignore[override]
|
|
243
245
|
def __get__(self, instance: None, owner: Any) -> ForwardManyToOneDescriptor: ...
|
|
244
246
|
# Model instance access
|
|
245
247
|
@overload
|
|
@@ -275,7 +277,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]):
|
|
|
275
277
|
blank: bool = ...,
|
|
276
278
|
null: Literal[False] = False,
|
|
277
279
|
db_index: bool = ...,
|
|
278
|
-
default: _M | Callable[[], _M]
|
|
280
|
+
default: _M | Callable[[], _M] = ...,
|
|
279
281
|
editable: bool = ...,
|
|
280
282
|
auto_created: bool = ...,
|
|
281
283
|
serialize: bool = ...,
|
|
@@ -285,6 +287,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]):
|
|
|
285
287
|
choices: Iterable[tuple[_M, str] | tuple[str, Iterable[tuple[_M, str]]]] = ...,
|
|
286
288
|
help_text: str = ...,
|
|
287
289
|
db_column: str | None = ...,
|
|
290
|
+
db_comment: str | None = ...,
|
|
288
291
|
db_tablespace: str | None = ...,
|
|
289
292
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
290
293
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
@@ -310,7 +313,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]):
|
|
|
310
313
|
blank: bool = ...,
|
|
311
314
|
null: Literal[True],
|
|
312
315
|
db_index: bool = ...,
|
|
313
|
-
default: _M | Callable[[], _M] = ...,
|
|
316
|
+
default: _M | Callable[[], _M | None] | None = ...,
|
|
314
317
|
editable: bool = ...,
|
|
315
318
|
auto_created: bool = ...,
|
|
316
319
|
serialize: bool = ...,
|
|
@@ -320,12 +323,13 @@ class OneToOneField(Generic[_M], ForeignKey[_M]):
|
|
|
320
323
|
choices: Iterable[tuple[_M, str] | tuple[str, Iterable[tuple[_M, str]]]] = ...,
|
|
321
324
|
help_text: str = ...,
|
|
322
325
|
db_column: str | None = ...,
|
|
326
|
+
db_comment: str | None = ...,
|
|
323
327
|
db_tablespace: str | None = ...,
|
|
324
328
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
325
329
|
error_messages: _ErrorMessagesToOverride | None = ...,
|
|
326
330
|
) -> OneToOneField[_M | None]: ...
|
|
327
331
|
# class access
|
|
328
|
-
@overload
|
|
332
|
+
@overload # type: ignore[override]
|
|
329
333
|
def __get__(self, instance: None, owner: Any) -> ForwardOneToOneDescriptor: ...
|
|
330
334
|
# Model instance access
|
|
331
335
|
@overload
|
|
@@ -388,6 +392,7 @@ class ManyToManyField(
|
|
|
388
392
|
choices: _FieldChoices | None = ...,
|
|
389
393
|
help_text: str = ...,
|
|
390
394
|
db_column: str | None = ...,
|
|
395
|
+
db_comment: str | None = ...,
|
|
391
396
|
db_table: str | None = ...,
|
|
392
397
|
db_tablespace: str | None = ...,
|
|
393
398
|
validators: Iterable[_ValidatorCallable] = ...,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from collections.abc import Iterable, Mapping
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from typing import Any, Generic, TypeVar
|
|
4
|
-
from typing_extensions import Self
|
|
5
4
|
|
|
6
5
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
|
7
6
|
from django.db.models.expressions import Expression, Func
|
|
@@ -10,6 +9,7 @@ from django.db.models.query_utils import RegisterLookupMixin
|
|
|
10
9
|
from django.db.models.sql.compiler import SQLCompiler
|
|
11
10
|
from django.utils.datastructures import OrderedSet
|
|
12
11
|
from django.utils.safestring import SafeText
|
|
12
|
+
from typing_extensions import Self
|
|
13
13
|
|
|
14
14
|
_T = TypeVar("_T")
|
|
15
15
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from collections.abc import Callable, Iterable, MutableMapping
|
|
2
2
|
from typing import Any, Generic, TypeVar
|
|
3
|
-
from typing_extensions import Self
|
|
4
3
|
|
|
5
4
|
from django.db.models.base import Model
|
|
6
5
|
from django.db.models.query import QuerySet
|
|
6
|
+
from typing_extensions import Self
|
|
7
7
|
|
|
8
8
|
_T = TypeVar("_T", bound=Model)
|
|
9
9
|
_V = TypeVar("_V", bound=Model)
|
|
@@ -57,6 +57,7 @@ class Options(Generic[_M]):
|
|
|
57
57
|
verbose_name: str | None = ...
|
|
58
58
|
verbose_name_plural: str | None = ...
|
|
59
59
|
db_table: str = ...
|
|
60
|
+
db_table_comment: str | None = ...
|
|
60
61
|
ordering: Sequence[str] | None = ...
|
|
61
62
|
indexes: list[Any] = ...
|
|
62
63
|
unique_together: list[Any] | tuple[Any, ...] = ...
|
django-stubs/db/models/query.pyi
CHANGED
|
@@ -10,15 +10,15 @@ from collections.abc import (
|
|
|
10
10
|
Sized,
|
|
11
11
|
)
|
|
12
12
|
from typing import Any, Generic, TypeVar, overload
|
|
13
|
-
from typing_extensions import Self
|
|
14
13
|
|
|
15
14
|
from django.db import models
|
|
16
15
|
from django.db.models import Manager
|
|
17
16
|
from django.db.models.base import Model
|
|
18
|
-
from django.db.models.expressions import Combinable as Combinable
|
|
17
|
+
from django.db.models.expressions import Combinable as Combinable
|
|
19
18
|
from django.db.models.expressions import F as F
|
|
20
|
-
from django.db.models.query_utils import Q as Q
|
|
19
|
+
from django.db.models.query_utils import Q as Q
|
|
21
20
|
from django.db.models.sql.query import Query, RawQuery
|
|
21
|
+
from typing_extensions import Self
|
|
22
22
|
|
|
23
23
|
_T = TypeVar("_T", bound=models.Model)
|
|
24
24
|
|
|
@@ -63,7 +63,7 @@ class _BaseQuerySet(Generic[_T], Sized):
|
|
|
63
63
|
objs: Iterable[_T],
|
|
64
64
|
batch_size: int | None = ...,
|
|
65
65
|
ignore_conflicts: bool = ...,
|
|
66
|
-
update_conflicts:
|
|
66
|
+
update_conflicts: bool | None = ...,
|
|
67
67
|
update_fields: Sequence[str] | None = ...,
|
|
68
68
|
unique_fields: Sequence[str] | None = ...,
|
|
69
69
|
) -> list[_T]: ...
|
|
@@ -112,10 +112,10 @@ class _BaseQuerySet(Generic[_T], Sized):
|
|
|
112
112
|
def raw(
|
|
113
113
|
self,
|
|
114
114
|
raw_query: str,
|
|
115
|
-
params: Any = ...,
|
|
115
|
+
params: tuple[Any] | list[Any] | dict[str, Any] = ...,
|
|
116
116
|
translations: dict[str, str] | None = ...,
|
|
117
117
|
using: str | None = ...,
|
|
118
|
-
) -> RawQuerySet[
|
|
118
|
+
) -> RawQuerySet[_T]: ...
|
|
119
119
|
# The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param
|
|
120
120
|
def values(
|
|
121
121
|
self, *fields: str | Combinable, **expressions: Any
|
django-stubs/db/utils.pyi
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from collections.abc import Callable, Iterable
|
|
2
2
|
from types import TracebackType
|
|
3
|
-
from typing import Any
|
|
3
|
+
from typing import Any, ParamSpec, TypeVar
|
|
4
4
|
from typing import Any as Incomplete
|
|
5
|
-
from typing import ParamSpec, TypeVar
|
|
6
5
|
|
|
7
6
|
from django.apps import AppConfig
|
|
8
7
|
from django.db.backends.base.base import BaseDatabaseWrapper
|