django-types 0.20.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.
- django-stubs/contrib/admin/actions.pyi +2 -2
- django-stubs/contrib/admin/decorators.pyi +4 -3
- django-stubs/contrib/admin/filters.pyi +5 -5
- django-stubs/contrib/admin/models.pyi +23 -11
- django-stubs/contrib/admin/options.pyi +5 -4
- django-stubs/contrib/admin/sites.pyi +11 -11
- django-stubs/contrib/admin/utils.pyi +2 -2
- django-stubs/contrib/admin/views/autocomplete.pyi +2 -2
- django-stubs/contrib/admin/views/main.pyi +6 -6
- django-stubs/contrib/admindocs/middleware.pyi +2 -2
- django-stubs/contrib/auth/admin.pyi +2 -2
- django-stubs/contrib/auth/backends.pyi +22 -0
- django-stubs/contrib/auth/base_user.pyi +2 -2
- django-stubs/contrib/auth/forms.pyi +1 -1
- django-stubs/contrib/auth/middleware.pyi +1 -2
- django-stubs/contrib/auth/models.pyi +24 -2
- django-stubs/contrib/auth/views.pyi +1 -2
- django-stubs/contrib/flatpages/middleware.pyi +2 -2
- django-stubs/contrib/flatpages/views.pyi +3 -3
- django-stubs/contrib/postgres/fields/array.pyi +1 -2
- django-stubs/contrib/postgres/fields/citext.pyi +1 -2
- django-stubs/contrib/postgres/fields/hstore.pyi +1 -2
- django-stubs/contrib/staticfiles/finders.pyi +1 -2
- django-stubs/contrib/staticfiles/views.pyi +2 -2
- django-stubs/contrib/syndication/views.pyi +4 -4
- django-stubs/core/exceptions.pyi +8 -6
- django-stubs/core/mail/__init__.pyi +1 -1
- django-stubs/core/mail/backends/base.pyi +1 -0
- django-stubs/db/backends/utils.pyi +1 -2
- django-stubs/db/migrations/operations/base.pyi +41 -16
- django-stubs/db/models/__init__.pyi +1 -0
- django-stubs/db/models/base.pyi +9 -2
- django-stubs/db/models/enums.pyi +2 -1
- django-stubs/db/models/fields/__init__.pyi +3 -3
- django-stubs/db/models/fields/composite.pyi +74 -0
- django-stubs/db/models/fields/json.pyi +2 -2
- django-stubs/db/models/fields/related.pyi +2 -2
- django-stubs/db/models/manager.pyi +2 -2
- django-stubs/db/utils.pyi +41 -16
- django-stubs/forms/formsets.pyi +6 -6
- django-stubs/forms/models.pyi +3 -4
- django-stubs/http/request.pyi +8 -4
- django-stubs/shortcuts.pyi +1 -2
- django-stubs/template/base.pyi +1 -1
- django-stubs/template/context_processors.pyi +1 -2
- django-stubs/test/client.pyi +9 -9
- django-stubs/test/testcases.pyi +2 -2
- django-stubs/urls/base.pyi +18 -2
- django-stubs/utils/cache.pyi +4 -4
- django-stubs/utils/connection.pyi +38 -0
- django-stubs/utils/datastructures.pyi +2 -2
- django-stubs/utils/translation/__init__.pyi +5 -3
- django-stubs/utils/translation/trans_real.pyi +2 -2
- django-stubs/views/generic/edit.pyi +1 -2
- {django_types-0.20.0.dist-info → django_types-0.22.0.dist-info}/METADATA +5 -6
- {django_types-0.20.0.dist-info → django_types-0.22.0.dist-info}/RECORD +58 -56
- {django_types-0.20.0.dist-info → django_types-0.22.0.dist-info}/WHEEL +1 -1
- {django_types-0.20.0.dist-info → django_types-0.22.0.dist-info}/LICENSE.txt +0 -0
|
@@ -25,7 +25,7 @@ def send_mail(
|
|
|
25
25
|
html_message: str | None = ...,
|
|
26
26
|
) -> int: ...
|
|
27
27
|
def send_mass_mail(
|
|
28
|
-
datatuple: list[tuple[str, str, str, list[str]]],
|
|
28
|
+
datatuple: list[tuple[str, str, str | None, list[str]]],
|
|
29
29
|
fail_silently: bool = ...,
|
|
30
30
|
auth_user: str | None = ...,
|
|
31
31
|
auth_password: str | None = ...,
|
|
@@ -6,6 +6,7 @@ from typing_extensions import Self
|
|
|
6
6
|
from django.core.mail.message import EmailMessage
|
|
7
7
|
|
|
8
8
|
class BaseEmailBackend:
|
|
9
|
+
fail_silently: bool
|
|
9
10
|
def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ...
|
|
10
11
|
def open(self) -> bool | None: ...
|
|
11
12
|
def close(self) -> None: ...
|
|
@@ -2,8 +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
|
|
6
|
-
from typing_extensions import Literal
|
|
5
|
+
from typing import IO, Any, Literal
|
|
7
6
|
from uuid import UUID
|
|
8
7
|
|
|
9
8
|
import psycopg2.extensions
|
|
@@ -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
|
-
|
|
10
|
-
def
|
|
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,
|
|
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,
|
|
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
|
|
19
|
-
def references_field(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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,
|
|
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
|
django-stubs/db/models/base.pyi
CHANGED
|
@@ -9,6 +9,7 @@ from django.core.exceptions import (
|
|
|
9
9
|
from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
|
10
10
|
from django.db.models.manager import BaseManager
|
|
11
11
|
from django.db.models.options import Options
|
|
12
|
+
from django.db.models.query import QuerySet
|
|
12
13
|
|
|
13
14
|
class ModelStateFieldsCacheDescriptor: ...
|
|
14
15
|
|
|
@@ -79,10 +80,16 @@ class Model(metaclass=ModelBase):
|
|
|
79
80
|
update_fields: Iterable[str] | None = ...,
|
|
80
81
|
) -> Any: ...
|
|
81
82
|
def refresh_from_db(
|
|
82
|
-
self,
|
|
83
|
+
self,
|
|
84
|
+
using: str | None = ...,
|
|
85
|
+
fields: list[str] | None = ...,
|
|
86
|
+
from_queryset: QuerySet[Self] | None = ...,
|
|
83
87
|
) -> None: ...
|
|
84
88
|
async def arefresh_from_db(
|
|
85
|
-
self,
|
|
89
|
+
self,
|
|
90
|
+
using: str | None = ...,
|
|
91
|
+
fields: list[str] | None = ...,
|
|
92
|
+
from_queryset: QuerySet[Self] | None = ...,
|
|
86
93
|
) -> None: ...
|
|
87
94
|
def get_deferred_fields(self) -> set[str]: ...
|
|
88
95
|
@classmethod
|
django-stubs/db/models/enums.pyi
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import decimal
|
|
2
2
|
import ipaddress
|
|
3
3
|
import uuid
|
|
4
|
-
from collections.abc import Callable, Iterable, Sequence
|
|
4
|
+
from collections.abc import Callable, Iterable, Mapping, Sequence
|
|
5
5
|
from datetime import date, datetime, time, timedelta
|
|
6
|
-
from typing import Any, Generic,
|
|
7
|
-
from typing_extensions import
|
|
6
|
+
from typing import Any, Generic, Literal, TypeVar, overload
|
|
7
|
+
from typing_extensions import Self
|
|
8
8
|
|
|
9
9
|
from django.core.checks import CheckMessage
|
|
10
10
|
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
|
@@ -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]]: ...
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from collections.abc import Callable, Iterable
|
|
3
|
-
from typing import Any, TypeVar, overload
|
|
4
|
-
from typing_extensions import
|
|
3
|
+
from typing import Any, Literal, TypeVar, overload
|
|
4
|
+
from typing_extensions import Self
|
|
5
5
|
|
|
6
6
|
from django.db.models import lookups
|
|
7
7
|
from django.db.models.expressions import Combinable
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from collections.abc import Callable, Iterable, Sequence
|
|
2
|
-
from typing import Any, Generic, Protocol, TypeVar, overload
|
|
3
|
-
from typing_extensions import
|
|
2
|
+
from typing import Any, Generic, Literal, Protocol, TypeVar, overload
|
|
3
|
+
from typing_extensions import Self
|
|
4
4
|
from uuid import UUID
|
|
5
5
|
|
|
6
6
|
from django.db import models
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from collections.abc import Iterable, MutableMapping
|
|
2
|
-
from typing import Any,
|
|
1
|
+
from collections.abc import Callable, Iterable, MutableMapping
|
|
2
|
+
from typing import Any, Generic, TypeVar
|
|
3
3
|
from typing_extensions import Self
|
|
4
4
|
|
|
5
5
|
from django.db.models.base import Model
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
41
|
+
def load_backend(backend_name: str) -> Any: ...
|
|
22
42
|
|
|
23
|
-
class ConnectionHandler:
|
|
24
|
-
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def
|
|
30
|
-
def
|
|
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 =
|
|
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]]: ...
|
django-stubs/forms/formsets.pyi
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from collections.abc import Iterator
|
|
1
|
+
from collections.abc import Iterator, Mapping
|
|
2
2
|
from typing import Any, Generic, TypeVar
|
|
3
3
|
|
|
4
4
|
from django.forms import BaseForm, Form
|
|
@@ -34,18 +34,18 @@ class BaseFormSet(Generic[_BaseFormT], RenderableFormMixin):
|
|
|
34
34
|
auto_id: str
|
|
35
35
|
data: dict[str, Any]
|
|
36
36
|
files: dict[str, Any]
|
|
37
|
-
initial: dict[str, Any] | None
|
|
37
|
+
initial: list[dict[str, Any]] | None
|
|
38
38
|
form_kwargs: dict[str, Any]
|
|
39
39
|
error_class: type[ErrorList]
|
|
40
40
|
error_messages: dict[str, Any]
|
|
41
41
|
|
|
42
42
|
def __init__(
|
|
43
43
|
self,
|
|
44
|
-
data:
|
|
45
|
-
files:
|
|
44
|
+
data: Mapping[str, Any] | None = ...,
|
|
45
|
+
files: Mapping[str, Any] | None = ...,
|
|
46
46
|
auto_id: str = ...,
|
|
47
47
|
prefix: str | None = ...,
|
|
48
|
-
initial: dict[str, Any] | None = ...,
|
|
48
|
+
initial: list[dict[str, Any]] | None = ...,
|
|
49
49
|
error_class: type[ErrorList] = ...,
|
|
50
50
|
form_kwargs: dict[str, Any] | None = ...,
|
|
51
51
|
error_messages: dict[str, Any] | None = ...,
|
|
@@ -109,7 +109,7 @@ class _FormSet(BaseFormSet[_BaseFormT]):
|
|
|
109
109
|
renderer: BaseRenderer
|
|
110
110
|
|
|
111
111
|
def formset_factory(
|
|
112
|
-
form: _BaseFormT,
|
|
112
|
+
form: type[_BaseFormT],
|
|
113
113
|
formset: type[BaseFormSet[_BaseFormT]] = ...,
|
|
114
114
|
extra: int = ...,
|
|
115
115
|
can_order: bool = ...,
|
django-stubs/forms/models.pyi
CHANGED
|
@@ -7,8 +7,7 @@ from collections.abc import (
|
|
|
7
7
|
Sequence,
|
|
8
8
|
)
|
|
9
9
|
from datetime import datetime
|
|
10
|
-
from typing import Any, ClassVar, Protocol, TypeVar
|
|
11
|
-
from typing_extensions import Literal
|
|
10
|
+
from typing import Any, ClassVar, Literal, Protocol, TypeVar
|
|
12
11
|
from unittest.mock import MagicMock
|
|
13
12
|
from uuid import UUID
|
|
14
13
|
|
|
@@ -258,7 +257,7 @@ class ModelChoiceField(ChoiceField):
|
|
|
258
257
|
empty_label: str | None = ...
|
|
259
258
|
queryset: Any = ...
|
|
260
259
|
limit_choices_to: dict[str, Any] | Callable[[], Any] | None = ...
|
|
261
|
-
to_field_name: None = ...
|
|
260
|
+
to_field_name: str | None = ...
|
|
262
261
|
def __init__(
|
|
263
262
|
self,
|
|
264
263
|
queryset: Manager[Any] | QuerySet[Any] | None,
|
|
@@ -269,7 +268,7 @@ class ModelChoiceField(ChoiceField):
|
|
|
269
268
|
label: Any | None = ...,
|
|
270
269
|
initial: Any | None = ...,
|
|
271
270
|
help_text: str = ...,
|
|
272
|
-
to_field_name:
|
|
271
|
+
to_field_name: str | None = ...,
|
|
273
272
|
limit_choices_to: dict[str, Any] | Callable[[], Any] | None = ...,
|
|
274
273
|
**kwargs: Any
|
|
275
274
|
) -> None: ...
|
django-stubs/http/request.pyi
CHANGED
|
@@ -3,8 +3,7 @@ from re import Pattern
|
|
|
3
3
|
from typing import Any, BinaryIO, TypeVar, overload
|
|
4
4
|
from typing_extensions import Self
|
|
5
5
|
|
|
6
|
-
from django.contrib.auth.
|
|
7
|
-
from django.contrib.auth.models import AnonymousUser
|
|
6
|
+
from django.contrib.auth.models import _AnyUser
|
|
8
7
|
from django.contrib.sessions.backends.base import SessionBase
|
|
9
8
|
from django.contrib.sites.models import Site
|
|
10
9
|
from django.core.files import uploadedfile, uploadhandler
|
|
@@ -96,9 +95,14 @@ class HttpRequest:
|
|
|
96
95
|
def __iter__(self) -> Iterable[bytes]: ...
|
|
97
96
|
def readlines(self) -> list[bytes]: ...
|
|
98
97
|
|
|
99
|
-
# Attributes added by
|
|
100
|
-
|
|
98
|
+
# Attributes added by optional parts of Django
|
|
99
|
+
# django.contrib.admin views:
|
|
100
|
+
current_app: str
|
|
101
|
+
# django.contrib.auth.middleware.AuthenticationMiddleware:
|
|
102
|
+
user: _AnyUser
|
|
103
|
+
# django.contrib.sites.middleware.CurrentSiteMiddleware
|
|
101
104
|
site: Site
|
|
105
|
+
# django.contrib.sessions.middleware.SessionMiddleware
|
|
102
106
|
session: SessionBase
|
|
103
107
|
|
|
104
108
|
class QueryDict(MultiValueDict[str, str]):
|
django-stubs/shortcuts.pyi
CHANGED
|
@@ -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
|
django-stubs/template/base.pyi
CHANGED
|
@@ -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:
|
|
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]: ...
|
django-stubs/test/client.pyi
CHANGED
|
@@ -70,7 +70,7 @@ class RequestFactory:
|
|
|
70
70
|
*,
|
|
71
71
|
QUERY_STRING: str = ...,
|
|
72
72
|
headers: Mapping[str, Any] | None = ...,
|
|
73
|
-
**extra:
|
|
73
|
+
**extra: object,
|
|
74
74
|
) -> WSGIRequest: ...
|
|
75
75
|
def post(
|
|
76
76
|
self,
|
|
@@ -81,7 +81,7 @@ class RequestFactory:
|
|
|
81
81
|
*,
|
|
82
82
|
QUERY_STRING: str = ...,
|
|
83
83
|
headers: Mapping[str, Any] | None = ...,
|
|
84
|
-
**extra:
|
|
84
|
+
**extra: object,
|
|
85
85
|
) -> WSGIRequest: ...
|
|
86
86
|
def head(
|
|
87
87
|
self,
|
|
@@ -91,7 +91,7 @@ class RequestFactory:
|
|
|
91
91
|
*,
|
|
92
92
|
QUERY_STRING: str = ...,
|
|
93
93
|
headers: Mapping[str, Any] | None = ...,
|
|
94
|
-
**extra:
|
|
94
|
+
**extra: object,
|
|
95
95
|
) -> WSGIRequest: ...
|
|
96
96
|
def trace(
|
|
97
97
|
self,
|
|
@@ -100,7 +100,7 @@ class RequestFactory:
|
|
|
100
100
|
*,
|
|
101
101
|
QUERY_STRING: str = ...,
|
|
102
102
|
headers: Mapping[str, Any] | None = ...,
|
|
103
|
-
**extra:
|
|
103
|
+
**extra: object,
|
|
104
104
|
) -> WSGIRequest: ...
|
|
105
105
|
def options(
|
|
106
106
|
self,
|
|
@@ -111,7 +111,7 @@ class RequestFactory:
|
|
|
111
111
|
*,
|
|
112
112
|
QUERY_STRING: str = ...,
|
|
113
113
|
headers: Mapping[str, Any] | None = ...,
|
|
114
|
-
**extra:
|
|
114
|
+
**extra: object,
|
|
115
115
|
) -> WSGIRequest: ...
|
|
116
116
|
def put(
|
|
117
117
|
self,
|
|
@@ -122,7 +122,7 @@ class RequestFactory:
|
|
|
122
122
|
*,
|
|
123
123
|
QUERY_STRING: str = ...,
|
|
124
124
|
headers: Mapping[str, Any] | None = ...,
|
|
125
|
-
**extra:
|
|
125
|
+
**extra: object,
|
|
126
126
|
) -> WSGIRequest: ...
|
|
127
127
|
def patch(
|
|
128
128
|
self,
|
|
@@ -133,7 +133,7 @@ class RequestFactory:
|
|
|
133
133
|
*,
|
|
134
134
|
QUERY_STRING: str = ...,
|
|
135
135
|
headers: Mapping[str, Any] | None = ...,
|
|
136
|
-
**extra:
|
|
136
|
+
**extra: object,
|
|
137
137
|
) -> WSGIRequest: ...
|
|
138
138
|
def delete(
|
|
139
139
|
self,
|
|
@@ -144,7 +144,7 @@ class RequestFactory:
|
|
|
144
144
|
*,
|
|
145
145
|
QUERY_STRING: str = ...,
|
|
146
146
|
headers: Mapping[str, Any] | None = ...,
|
|
147
|
-
**extra:
|
|
147
|
+
**extra: object,
|
|
148
148
|
) -> WSGIRequest: ...
|
|
149
149
|
def generic(
|
|
150
150
|
self,
|
|
@@ -156,7 +156,7 @@ class RequestFactory:
|
|
|
156
156
|
*,
|
|
157
157
|
QUERY_STRING: str = ...,
|
|
158
158
|
headers: Mapping[str, Any] | None = ...,
|
|
159
|
-
**extra:
|
|
159
|
+
**extra: object,
|
|
160
160
|
) -> WSGIRequest: ...
|
|
161
161
|
|
|
162
162
|
class Client(RequestFactory):
|
django-stubs/test/testcases.pyi
CHANGED
|
@@ -148,13 +148,13 @@ class SimpleTestCase(unittest.TestCase):
|
|
|
148
148
|
) -> None: ...
|
|
149
149
|
def assertJSONEqual(
|
|
150
150
|
self,
|
|
151
|
-
raw: str,
|
|
151
|
+
raw: str | bytes | bytearray,
|
|
152
152
|
expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None,
|
|
153
153
|
msg: str | None = ...,
|
|
154
154
|
) -> None: ...
|
|
155
155
|
def assertJSONNotEqual(
|
|
156
156
|
self,
|
|
157
|
-
raw: str,
|
|
157
|
+
raw: str | bytes | bytearray,
|
|
158
158
|
expected_data: dict[str, Any] | list[Any] | str | int | float | bool | None,
|
|
159
159
|
msg: str | None = ...,
|
|
160
160
|
) -> None: ...
|
django-stubs/urls/base.pyi
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
from collections.abc import Callable, Sequence
|
|
2
|
-
from typing import Any
|
|
1
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
2
|
+
from typing import Any, TypeAlias
|
|
3
3
|
|
|
4
|
+
from django.http.request import QueryDict
|
|
4
5
|
from django.urls.resolvers import ResolverMatch
|
|
5
6
|
|
|
7
|
+
# The values are passed through `str()` (unless they are bytes), so anything is valid.
|
|
8
|
+
_QueryType: TypeAlias = (
|
|
9
|
+
Mapping[str, object]
|
|
10
|
+
| Mapping[bytes, object]
|
|
11
|
+
| Mapping[str | bytes, object]
|
|
12
|
+
| Mapping[str, Sequence[object]]
|
|
13
|
+
| Mapping[bytes, Sequence[object]]
|
|
14
|
+
| Mapping[str | bytes, Sequence[object]]
|
|
15
|
+
| Sequence[tuple[str | bytes, object]]
|
|
16
|
+
| Sequence[tuple[str | bytes, Sequence[object]]]
|
|
17
|
+
)
|
|
18
|
+
|
|
6
19
|
def resolve(path: str, urlconf: str | None = ...) -> ResolverMatch: ...
|
|
7
20
|
def reverse(
|
|
8
21
|
viewname: Callable[..., Any] | str | None,
|
|
@@ -10,6 +23,9 @@ def reverse(
|
|
|
10
23
|
args: Sequence[Any] | None = ...,
|
|
11
24
|
kwargs: dict[str, Any] | None = ...,
|
|
12
25
|
current_app: str | None = ...,
|
|
26
|
+
*,
|
|
27
|
+
query: QueryDict | _QueryType | None = ...,
|
|
28
|
+
fragment: str | None = ...,
|
|
13
29
|
) -> str: ...
|
|
14
30
|
|
|
15
31
|
reverse_lazy: Any
|
django-stubs/utils/cache.pyi
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
3
|
from django.core.cache.backends.base import BaseCache
|
|
4
|
-
from django.
|
|
4
|
+
from django.http.request import HttpRequest
|
|
5
5
|
from django.http.response import HttpResponse, HttpResponseBase
|
|
6
6
|
|
|
7
7
|
cc_delim_re: Any
|
|
@@ -10,7 +10,7 @@ def patch_cache_control(response: HttpResponseBase, **kwargs: Any) -> None: ...
|
|
|
10
10
|
def get_max_age(response: HttpResponse) -> int | None: ...
|
|
11
11
|
def set_response_etag(response: HttpResponseBase) -> HttpResponseBase: ...
|
|
12
12
|
def get_conditional_response(
|
|
13
|
-
request:
|
|
13
|
+
request: HttpRequest,
|
|
14
14
|
etag: str | None = ...,
|
|
15
15
|
last_modified: int | None = ...,
|
|
16
16
|
response: HttpResponse | None = ...,
|
|
@@ -22,13 +22,13 @@ def add_never_cache_headers(response: HttpResponseBase) -> None: ...
|
|
|
22
22
|
def patch_vary_headers(response: HttpResponseBase, newheaders: tuple[str]) -> None: ...
|
|
23
23
|
def has_vary_header(response: HttpResponse, header_query: str) -> bool: ...
|
|
24
24
|
def get_cache_key(
|
|
25
|
-
request:
|
|
25
|
+
request: HttpRequest,
|
|
26
26
|
key_prefix: str | None = ...,
|
|
27
27
|
method: str = ...,
|
|
28
28
|
cache: BaseCache | None = ...,
|
|
29
29
|
) -> str | None: ...
|
|
30
30
|
def learn_cache_key(
|
|
31
|
-
request:
|
|
31
|
+
request: HttpRequest,
|
|
32
32
|
response: HttpResponse,
|
|
33
33
|
cache_timeout: float | None = ...,
|
|
34
34
|
key_prefix: str | None = ...,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from collections.abc import Iterator
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from django.db.backends.base.base import BaseDatabaseWrapper
|
|
6
|
+
from django.utils.functional import cached_property
|
|
7
|
+
|
|
8
|
+
class ConnectionProxy:
|
|
9
|
+
"""Proxy for accessing a connection object's attributes."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, connections: BaseConnectionHandler, alias: str) -> None: ...
|
|
12
|
+
def __getattr__(self, item: str) -> Any: ...
|
|
13
|
+
def __setattr__(self, name: str, value: Any) -> None: ...
|
|
14
|
+
def __delattr__(self, name: str) -> None: ...
|
|
15
|
+
def __contains__(self, key: str) -> bool: ...
|
|
16
|
+
def __eq__(self, other: object) -> bool: ...
|
|
17
|
+
|
|
18
|
+
class ConnectionDoesNotExist(Exception): ...
|
|
19
|
+
|
|
20
|
+
class BaseConnectionHandler:
|
|
21
|
+
settings_name: str | None
|
|
22
|
+
exception_class: type[Exception]
|
|
23
|
+
thread_critical: bool
|
|
24
|
+
|
|
25
|
+
def __init__(self, settings: dict[str, dict[str, Any]] | None = None) -> None: ...
|
|
26
|
+
@cached_property
|
|
27
|
+
def settings(self) -> dict[str, dict[str, Any]]: ...
|
|
28
|
+
def configure_settings(
|
|
29
|
+
self, settings: dict[str, dict[str, Any]] | None
|
|
30
|
+
) -> dict[str, dict[str, Any]]: ...
|
|
31
|
+
@abstractmethod
|
|
32
|
+
def create_connection(self, alias: str) -> BaseDatabaseWrapper: ...
|
|
33
|
+
def __getitem__(self, alias: str) -> BaseDatabaseWrapper: ...
|
|
34
|
+
def __setitem__(self, key: str, value: BaseDatabaseWrapper) -> None: ...
|
|
35
|
+
def __delitem__(self, key: str) -> None: ...
|
|
36
|
+
def __iter__(self) -> Iterator[str]: ...
|
|
37
|
+
def all(self, initialized_only: bool = False) -> list[BaseDatabaseWrapper]: ...
|
|
38
|
+
def close_all(self) -> None: ...
|