django-types 0.21.0__py3-none-any.whl → 0.22.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.
@@ -1,25 +1,50 @@
1
+ import enum
2
+ from collections.abc import Sequence
1
3
  from typing import Any
4
+ from typing_extensions import Self
5
+
6
+ from django.db.backends.base.schema import BaseDatabaseSchemaEditor
7
+ from django.db.migrations.state import ProjectState
8
+ from django.db.models import Model
9
+
10
+ class OperationCategory(str, enum.Enum):
11
+ ADDITION = "+"
12
+ REMOVAL = "-"
13
+ ALTERATION = "~"
14
+ PYTHON = "p"
15
+ SQL = "s"
16
+ MIXED = "?"
2
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: ...
@@ -92,6 +92,7 @@ from .fields.related import ManyToManyRel as ManyToManyRel
92
92
  from .fields.related import ManyToOneRel as ManyToOneRel
93
93
  from .fields.related import OneToOneField as OneToOneField
94
94
  from .fields.related import OneToOneRel as OneToOneRel
95
+ from .fields.composite import CompositePrimaryKey as CompositePrimaryKey
95
96
  from .indexes import Index as Index
96
97
  from .lookups import Lookup as Lookup
97
98
  from .lookups import Transform as Transform
@@ -0,0 +1,74 @@
1
+ from collections.abc import Iterable, Iterator, Mapping
2
+ from typing import Any, Literal
3
+
4
+ from django.contrib.contenttypes.fields import GenericForeignKey
5
+
6
+ from django.db.models.fields import NOT_PROVIDED, Field
7
+ from django.db.models.base import Model
8
+ from django.db.models.fields.reverse_related import ForeignObjectRel
9
+ from django.utils.functional import cached_property
10
+
11
+ StrOrPromise = str
12
+ from django.db.models.fields import Field, _ValidatorCallable, _LiteralFieldChoices
13
+
14
+ class AttributeSetter:
15
+ def __init__(self, name: str, value: Any) -> None: ...
16
+
17
+ class CompositeAttribute:
18
+ field: CompositePrimaryKey
19
+ def __init__(self, field: CompositePrimaryKey) -> None: ...
20
+ @property
21
+ def attnames(self) -> list[str]: ...
22
+ def __get__(
23
+ self, instance: Model, cls: type[Model] | None = None
24
+ ) -> tuple[Any, ...]: ...
25
+ def __set__(
26
+ self, instance: Model, values: list[Any] | tuple[Any] | None
27
+ ) -> None: ...
28
+
29
+ class CompositePrimaryKey(Field[tuple[Any, ...] | None, tuple[Any, ...] | None]):
30
+ field_names: tuple[str]
31
+ descriptor_class: type[CompositeAttribute]
32
+ def __init__(
33
+ self,
34
+ *args: str,
35
+ verbose_name: StrOrPromise | None = None,
36
+ name: str | None = None,
37
+ primary_key: Literal[True] = True,
38
+ max_length: int | None = None,
39
+ unique: bool = False,
40
+ blank: Literal[True] = True,
41
+ null: bool = False,
42
+ db_index: bool = False,
43
+ rel: ForeignObjectRel | None = None,
44
+ default: type[NOT_PROVIDED] = ...,
45
+ editable: Literal[False] = False,
46
+ serialize: bool = True,
47
+ unique_for_date: str | None = None,
48
+ unique_for_month: str | None = None,
49
+ unique_for_year: str | None = None,
50
+ choices: _LiteralFieldChoices | None = None,
51
+ help_text: StrOrPromise = "",
52
+ db_column: None = None,
53
+ db_tablespace: str | None = None,
54
+ auto_created: bool = False,
55
+ validators: Iterable[_ValidatorCallable] = (),
56
+ error_messages: Mapping[str, StrOrPromise] | None = None,
57
+ db_comment: str | None = None,
58
+ db_default: type[NOT_PROVIDED] = ...,
59
+ ) -> None: ...
60
+ @cached_property
61
+ def fields(
62
+ self,
63
+ ) -> tuple[Field[Any, Any] | ForeignObjectRel | GenericForeignKey, ...]: ...
64
+ @cached_property
65
+ def columns(self) -> tuple[str, ...]: ...
66
+ def __iter__(
67
+ self,
68
+ ) -> Iterator[Field[Any, Any] | ForeignObjectRel | GenericForeignKey]: ...
69
+ def __len__(self) -> int: ...
70
+ def get_pk_value_on_save(
71
+ self, instance: Model
72
+ ) -> tuple[Any, ...] | None: ... # actual type is tuple of field.value_from_object
73
+
74
+ def unnest(fields: Iterable[Field[Any, Any]]) -> list[Field[Any, Any]]: ...
django-stubs/db/utils.pyi CHANGED
@@ -1,7 +1,17 @@
1
- from collections.abc import Iterable
1
+ from collections.abc import Callable, Iterable
2
+ from types import TracebackType
2
3
  from typing import Any
4
+ from typing import Any as Incomplete
5
+ from typing import ParamSpec, TypeVar
3
6
 
4
- from django.db import DefaultConnectionProxy
7
+ from django.apps import AppConfig
8
+ from django.db.backends.base.base import BaseDatabaseWrapper
9
+ from django.db.models import Model
10
+ from django.utils.connection import BaseConnectionHandler
11
+ from django.utils.connection import ConnectionDoesNotExist as ConnectionDoesNotExist
12
+
13
+ _P = ParamSpec("_P")
14
+ _R = TypeVar("_R")
5
15
 
6
16
  DEFAULT_DB_ALIAS: str
7
17
  DJANGO_VERSION_PICKLE_KEY: str
@@ -16,23 +26,38 @@ class InternalError(DatabaseError): ...
16
26
  class ProgrammingError(DatabaseError): ...
17
27
  class NotSupportedError(DatabaseError): ...
18
28
 
19
- def load_backend(backend_name: str) -> Any: ...
29
+ class DatabaseErrorWrapper:
30
+ wrapper: Incomplete
31
+ def __init__(self, wrapper: Incomplete) -> None: ...
32
+ def __enter__(self) -> None: ...
33
+ def __exit__(
34
+ self,
35
+ exc_type: type[BaseException] | None,
36
+ exc_value: BaseException | None,
37
+ traceback: TracebackType | None,
38
+ ) -> None: ...
39
+ def __call__(self, func: Callable[_P, _R]) -> Callable[_P, _R]: ...
20
40
 
21
- class ConnectionDoesNotExist(Exception): ...
41
+ def load_backend(backend_name: str) -> Any: ...
22
42
 
23
- class ConnectionHandler:
24
- databases: dict[str, dict[str, Any | None]]
25
- def __init__(self, databases: dict[str, dict[str, Any | None]] = ...) -> None: ...
26
- def ensure_defaults(self, alias: str) -> None: ...
27
- def prepare_test_settings(self, alias: str) -> None: ...
28
- def __getitem__(self, alias: str) -> DefaultConnectionProxy: ...
29
- def __setitem__(self, key: Any, value: Any) -> None: ...
30
- def __delitem__(self, key: Any) -> None: ...
31
- def __iter__(self) -> Any: ...
32
- def all(self) -> list[Any]: ...
33
- def close_all(self) -> None: ...
43
+ class ConnectionHandler(BaseConnectionHandler):
44
+ settings_name: str # pyright: ignore[reportIncompatibleVariableOverride]
45
+ def configure_settings(
46
+ self, databases: dict[str, dict[str, Any]] | None
47
+ ) -> dict[str, dict[str, Any]]: ...
48
+ @property
49
+ def databases(self) -> dict[str, dict[str, Any]]: ...
50
+ def create_connection(self, alias: str) -> BaseDatabaseWrapper: ...
34
51
 
35
52
  class ConnectionRouter:
36
- def __init__(self, routers: Iterable[Any] | None = ...) -> None: ...
53
+ def __init__(self, routers: Iterable[Any] | None = None) -> None: ...
37
54
  @property
38
55
  def routers(self) -> list[Any]: ...
56
+ def db_for_read(self, model: type[Model], **hints: Any) -> str: ...
57
+ def db_for_write(self, model: type[Model], **hints: Any) -> str: ...
58
+ def allow_relation(self, obj1: Model, obj2: Model, **hints: Any) -> bool: ...
59
+ def allow_migrate(self, db: str, app_label: str, **hints: Any) -> bool: ...
60
+ def allow_migrate_model(self, db: str, model: type[Model]) -> bool: ...
61
+ def get_migratable_models(
62
+ self, app_config: AppConfig, db: str, include_auto_created: bool = False
63
+ ) -> list[type[Model]]: ...
@@ -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: ...
@@ -1,7 +1,8 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.1
2
2
  Name: django-types
3
- Version: 0.21.0
3
+ Version: 0.22.0
4
4
  Summary: Type stubs for Django
5
+ Home-page: https://github.com/sbdchd/django-types
5
6
  License: MIT
6
7
  Keywords: django,types,mypy,stubs
7
8
  Author: Steve Dignam
@@ -12,7 +13,6 @@ Classifier: Programming Language :: Python :: 3
12
13
  Classifier: Programming Language :: Python :: 3.10
13
14
  Classifier: Programming Language :: Python :: 3.11
14
15
  Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Dist: types-psycopg2 (>=2.9.21.13)
17
17
  Project-URL: Repository, https://github.com/sbdchd/django-types
18
18
  Description-Content-Type: text/markdown
@@ -477,7 +477,7 @@ django-stubs/db/migrations/graph.pyi,sha256=ja1QsjHieh1aPUSX-xZLEmoaXvVfTs-VI9-O
477
477
  django-stubs/db/migrations/loader.pyi,sha256=zcSH4L0j7dr2JNimtUCkFhPHp5o0O1mausmqoMVkO0c,1880
478
478
  django-stubs/db/migrations/migration.pyi,sha256=GHIgBLPD7xme34SW5QN11fdHNWYsSThI6WcF1ulb4uk,1226
479
479
  django-stubs/db/migrations/operations/__init__.pyi,sha256=mdERH-9nMnUC7YCRFYmT1N-ob_nvCz2pk9NNWNWGkCs,1043
480
- django-stubs/db/migrations/operations/base.pyi,sha256=IQegK9pLOM7BgKMAYxbyPzHTcUFR71WT4k1MaVWBkd0,974
480
+ django-stubs/db/migrations/operations/base.pyi,sha256=dPPEmi_TYA4rCecoJThGNLhi3ykVtOUkJZ64u6T4mR4,1614
481
481
  django-stubs/db/migrations/operations/fields.pyi,sha256=av6YKj3LAvq-nQ74E-yMzCOjkqEz8HBge_5jaObbObw,1309
482
482
  django-stubs/db/migrations/operations/models.pyi,sha256=tDlZv2tH_1brVH66iNU12zK_YqBKC9nGtuF4D16XboY,3595
483
483
  django-stubs/db/migrations/operations/special.pyi,sha256=aeNVSpuZYMZMMi6O-gYLpYOsTFh1YSkK7574zWrSR4c,1384
@@ -490,7 +490,7 @@ django-stubs/db/migrations/state.pyi,sha256=5na7eUY-FnPqAuuPTeC897JhlIQotE2Pbml-
490
490
  django-stubs/db/migrations/topological_sort.pyi,sha256=rlYIxXKWR80LL1XH7W1IAu4P2m5QNoc51oXi3hK-rr8,359
491
491
  django-stubs/db/migrations/utils.pyi,sha256=yRlE8__8quhMrlAMU1F282hQftrxxiSQbja20o8hYmc,207
492
492
  django-stubs/db/migrations/writer.pyi,sha256=xtzy4LKWLn3SAgSsC_2Xd63s76ZaoS7Cjuzy6IolAwI,1432
493
- django-stubs/db/models/__init__.pyi,sha256=4Y1JU2ku0boVqRWOcFhUifao5CaurvaeVBBTWGD3G7s,4977
493
+ django-stubs/db/models/__init__.pyi,sha256=JVppMs5MCLrQ7TL9h1SmhLXeg8sDfLmgdM2tgzsHaUk,5050
494
494
  django-stubs/db/models/aggregates.pyi,sha256=u4q_ubpu4Ng7m500-jIUvHRUV9zrV3yeCrbUTVhADCI,534
495
495
  django-stubs/db/models/base.pyi,sha256=u6NYwyPRCDbeQSI06qxqkmvXtu-wuSlyybnqU3WeM9s,3337
496
496
  django-stubs/db/models/constants.pyi,sha256=ood04pB_pIazVlP0TRWY43rbcGwwj43w_moVTODQXxY,22
@@ -499,6 +499,7 @@ django-stubs/db/models/deletion.pyi,sha256=fkFrzTvXTHrfdRUqPR0XPLLZ45rr1vxB7RuSQ
499
499
  django-stubs/db/models/enums.pyi,sha256=sbl9ZwQ4bR41FPQZfWfVeIq5k4rdJjYyK_lk9G2HN0Q,786
500
500
  django-stubs/db/models/expressions.pyi,sha256=afDeeoU2wh2DKQtNvOEPK5xXkknneRaf-Shor6HSL-8,8833
501
501
  django-stubs/db/models/fields/__init__.pyi,sha256=hBKbKe3kNg-oQC6iE3m2r-QMXCfbV58XluXzWMZiHeU,58896
502
+ django-stubs/db/models/fields/composite.pyi,sha256=gP6mX7gIqJUf125P93VxXOUP_M-sVehMv-GUPLnYwCE,2742
502
503
  django-stubs/db/models/fields/files.pyi,sha256=3VR0Da5c2OwhwI1OyMFeoOQGEiGbmqkrSseksHK66vk,4822
503
504
  django-stubs/db/models/fields/json.pyi,sha256=_ndRMJauwKRc-L8gmVs4GKR7aBac6BBGyrEIkdGybbw,7131
504
505
  django-stubs/db/models/fields/mixins.pyi,sha256=bXN6K81lsnr24r0s2XkW83se29q9VhvAIUr_DU3zhsk,515
@@ -530,7 +531,7 @@ django-stubs/db/models/sql/subqueries.pyi,sha256=_gYu7mK_GGwBBlRPETBxU_DLIf95vS3
530
531
  django-stubs/db/models/sql/where.pyi,sha256=6n4RscrshnVzl3D__Kd-VuUjXQf05oScYDHSdXo9FhA,1962
531
532
  django-stubs/db/models/utils.pyi,sha256=AkApadOHnIPZa9yKnfm-MEfr0FWcsGTgEd_HNibdktQ,112
532
533
  django-stubs/db/transaction.pyi,sha256=G4UC6UQ3I1BZVkKnxRgkdf7cgYcR5paELfHKgWK0gUU,2215
533
- django-stubs/db/utils.pyi,sha256=oyeE2_pXhWMyvZwbPZZL41cpIXqmyOfjYEEeBSxuvZw,1312
534
+ django-stubs/db/utils.pyi,sha256=7zw1cYsfrf7SD3_hqj8ror7D91YQSyIbFlUpHwLdJ_8,2411
534
535
  django-stubs/dispatch/__init__.pyi,sha256=NDJ95BCbvsMHzAFlZ3YY1uJeP52FpW8cBmaYXz-6RzM,116
535
536
  django-stubs/dispatch/dispatcher.pyi,sha256=p_L7ixmsplHeQ55bm4ixs4JMf7Cd8BwBA3qU-qrNobg,1111
536
537
  django-stubs/forms/__init__.pyi,sha256=SW8ETbx3N_BH-z53VE7OVpB_HCeqz0RjKptAcE5y3lY,4112
@@ -612,6 +613,7 @@ django-stubs/utils/asyncio.pyi,sha256=Zhj1jPnjD0TUIXFc4TjagDNZCfemSOhgTcBWBzWU3L
612
613
  django-stubs/utils/autoreload.pyi,sha256=J48GZdgZ99PUZkA-tm8j-nBJmJkJLOoCVKVOqLDUeRI,2732
613
614
  django-stubs/utils/baseconv.pyi,sha256=Do74JAMtaFAECKBgmeeDha6UJh_GanWEPtS-Elolb3c,587
614
615
  django-stubs/utils/cache.pyi,sha256=nbe4lNNo1AgD_2Q4MGQrLGCJ1HjsviHzktLuehg3aH4,1301
616
+ django-stubs/utils/connection.pyi,sha256=mDZ0IFecjakg3F7GI9so1qoIzHyhGRkvjDhXvM_LkPA,1548
615
617
  django-stubs/utils/crypto.pyi,sha256=H3kBooKkvUu_-gmKdVFEIzxKOu-d92fsV_o_5kueffs,532
616
618
  django-stubs/utils/datastructures.pyi,sha256=Rym3AUb6bLWg5nxMCT2bo50CQmNtDujNy606ontVcUI,2843
617
619
  django-stubs/utils/dateformat.pyi,sha256=-aVTA8izjEflilwgfZ-bRxRLE5n64NsTzfg_3T4mYLM,1814
@@ -673,7 +675,7 @@ django-stubs/views/generic/edit.pyi,sha256=VDpl-ndt-P8eNrCErFbXkGQ4gz8v-Dd04A0FY
673
675
  django-stubs/views/generic/list.pyi,sha256=uEROJ5MtL4MLRFMNIt0Jyg2YA1HbF09IabKstz3TOOA,1716
674
676
  django-stubs/views/i18n.pyi,sha256=Bk9BeKN-T_5ns_wjIxK3cwRIB6OppAKTEzkAqcfQd08,1281
675
677
  django-stubs/views/static.pyi,sha256=tqWLCR9PAlKPfPtmPoUF87Jiit5tXouD7mNp_0kHBDI,467
676
- django_types-0.21.0.dist-info/LICENSE.txt,sha256=tGt1CLamvQHwnLata-U8u3-oGSsO5n50EchxJT77RaI,1102
677
- django_types-0.21.0.dist-info/METADATA,sha256=Tu7eB2DGDkrD6IaOtQpd7M5bcf2CoxuoGafKWST8Ztg,7716
678
- django_types-0.21.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
679
- django_types-0.21.0.dist-info/RECORD,,
678
+ django_types-0.22.0.dist-info/LICENSE.txt,sha256=tGt1CLamvQHwnLata-U8u3-oGSsO5n50EchxJT77RaI,1102
679
+ django_types-0.22.0.dist-info/METADATA,sha256=ytBFR06lFcxT1qRmfjfxpWz3zHKE2U-n94GmP-JTF5I,7715
680
+ django_types-0.22.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
681
+ django_types-0.22.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 1.8.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any