improved version

This commit is contained in:
Maxim Kurnikov
2018-07-29 20:06:41 +03:00
parent c180555415
commit 89bb6eac75
160 changed files with 1007 additions and 607 deletions

View File

@@ -15,4 +15,4 @@ def reset_queries(**kwargs) -> None: ...
class DefaultConnectionProxy:
def __eq__(self, other: DatabaseWrapper) -> bool: ...
def __getattr__(self, item: str) -> Any: ...
def __setattr__(self, name: str, value: Union[MagicMock, bool]) -> None: ...
def __setattr__(self, name: str, value: Union[bool, MagicMock]) -> None: ...

View File

@@ -27,5 +27,5 @@ class BaseDatabaseCreation:
suffix: None = ...
) -> None: ...
def serialize_db_to_string(self) -> str: ...
def set_as_test_mirror(self, primary_settings_dict: Dict[str, Union[str, int, None, Dict[str, None]]]) -> None: ...
def set_as_test_mirror(self, primary_settings_dict: Dict[str, Optional[Union[str, int, Dict[str, None]]]]) -> None: ...
def test_db_signature(self) -> Tuple[str, str, str, str]: ...

View File

@@ -5,18 +5,27 @@ from datetime import (
timedelta,
)
from decimal import Decimal
from django.contrib.auth.models import (
Group,
User,
)
from django.contrib.sites.models import Site
from django.core.management.color import Style
from django.db import DefaultConnectionProxy
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.backends.utils import CursorWrapper
from django.db.models.base import Model
from django.db.models.expressions import Expression
from django.db.models.fields import Field
from django.db.models.sql.compiler import SQLCompiler
from typing import (
Any,
List,
Optional,
Set,
Tuple,
Type,
Union,
)
@@ -35,15 +44,15 @@ class BaseDatabaseOperations:
decimal_places: Optional[int] = ...
) -> Optional[str]: ...
def adapt_ipaddressfield_value(self, value: Optional[str]) -> Optional[str]: ...
def adapt_timefield_value(self, value: Optional[Union[time, datetime]]) -> Optional[str]: ...
def adapt_unknown_value(self, value: Union[Decimal, time, date, int]) -> Union[str, int]: ...
def adapt_timefield_value(self, value: Optional[Union[datetime, time]]) -> Optional[str]: ...
def adapt_unknown_value(self, value: Union[date, time, int, Decimal]) -> Union[str, int]: ...
def autoinc_sql(self, table: str, column: str) -> None: ...
def binary_placeholder_sql(self, value: Optional[memoryview]) -> str: ...
def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ...
def compiler(self, compiler_name: str) -> Any: ...
def compiler(self, compiler_name: str) -> Type[SQLCompiler]: ...
def convert_durationfield_value(
self,
value: Optional[Union[float, int]],
value: Optional[float],
expression: Expression,
connection: DatabaseWrapper
) -> Optional[timedelta]: ...
@@ -70,7 +79,11 @@ class BaseDatabaseOperations:
def savepoint_create_sql(self, sid: str) -> str: ...
def savepoint_rollback_sql(self, sid: str) -> str: ...
def sequence_reset_by_name_sql(self, style: None, sequences: List[Any]) -> List[Any]: ...
def sequence_reset_sql(self, style: Style, model_list: Any) -> List[Any]: ...
def sequence_reset_sql(
self,
style: Style,
model_list: Union[Set[Type[Model]], List[Type[Model]], Set[Type[Union[Group, User]]], List[Type[Site]]]
) -> List[Any]: ...
def set_time_zone_sql(self) -> str: ...
def tablespace_sql(self, tablespace: str, inline: bool = ...) -> str: ...
def time_extract_sql(self, lookup_type: None, field_name: None): ...

View File

@@ -37,12 +37,12 @@ class BaseDatabaseSchemaEditor:
def _create_index_name(
self,
table_name: str,
column_names: Union[Tuple[str, str, str], Tuple[str], List[str]],
column_names: Union[Tuple[str, str, str], List[str], Tuple[str]],
suffix: str = ...
) -> str: ...
def _create_index_sql(
self,
model: Any,
model: Type[Model],
fields: Any,
*,
name = ...,
@@ -52,7 +52,11 @@ class BaseDatabaseSchemaEditor:
col_suffixes = ...,
sql = ...
) -> Statement: ...
def _create_unique_sql(self, model: Any, columns: List[str]) -> Statement: ...
def _create_unique_sql(
self,
model: Type[Model],
columns: List[str]
) -> Statement: ...
def _delete_composed_index(
self,
model: Type[Model],
@@ -64,6 +68,6 @@ class BaseDatabaseSchemaEditor:
def _digest(cls, *args) -> str: ...
def _field_indexes_sql(
self,
model: Any,
model: Type[Model],
field: Field
) -> List[Statement]: ...

View File

@@ -7,4 +7,4 @@ from typing import (
class DatabaseClient:
@classmethod
def settings_to_cmd_args(cls, settings_dict: Dict[str, Union[str, None]]) -> List[str]: ...
def settings_to_cmd_args(cls, settings_dict: Dict[str, Optional[str]]) -> List[str]: ...

View File

@@ -78,5 +78,5 @@ class SQLiteCursorWrapper:
def executemany(
self,
query: str,
param_list: Union[List[Tuple[int]], List[Tuple[int, int]]]
param_list: Union[List[Tuple[int, int]], List[Tuple[int]]]
) -> SQLiteCursorWrapper: ...

View File

@@ -27,7 +27,7 @@ class DatabaseIntrospection:
self,
cursor: CursorWrapper,
name: str
) -> List[Dict[str, Union[str, None, int]]]: ...
) -> List[Dict[str, Optional[Union[str, int]]]]: ...
def get_constraints(
self,
cursor: CursorWrapper,

View File

@@ -10,14 +10,19 @@ from django.db.backends.sqlite3.base import (
SQLiteCursorWrapper,
)
from django.db.backends.utils import CursorDebugWrapper
from django.db.models.aggregates import Aggregate
from django.db.models.aggregates import (
Aggregate,
Max,
)
from django.db.models.expressions import (
BaseExpression,
Col,
CombinedExpression,
Expression,
F,
OrderBy,
)
from django.db.models.functions.comparison import Cast
from django.db.models.functions.datetime import TruncBase
from typing import (
Any,
Callable,
@@ -40,7 +45,10 @@ class DatabaseOperations:
def adapt_timefield_value(self, value: Optional[time]) -> Optional[str]: ...
def bulk_batch_size(self, fields: Any, objs: Any) -> int: ...
def bulk_insert_sql(self, fields: Any, placeholder_rows: Any) -> str: ...
def check_expression_support(self, expression: BaseExpression) -> None: ...
def check_expression_support(
self,
expression: Union[OrderBy, Expression]
) -> None: ...
def combine_duration_expression(self, connector: str, sub_expressions: List[str]) -> str: ...
def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ...
def convert_booleanfield_value(
@@ -52,7 +60,7 @@ class DatabaseOperations:
def convert_datefield_value(
self,
value: Optional[Union[str, date]],
expression: Expression,
expression: Union[Col, Cast, Aggregate, django.db.models.functions.TruncBase],
connection: DatabaseWrapper
) -> Optional[date]: ...
def convert_datetimefield_value(
@@ -64,7 +72,7 @@ class DatabaseOperations:
def convert_timefield_value(
self,
value: Optional[Union[str, time]],
expression: Expression,
expression: Union[Col, Max, django.db.models.functions.TruncBase],
connection: DatabaseWrapper
) -> Optional[time]: ...
def convert_uuidfield_value(
@@ -92,7 +100,7 @@ class DatabaseOperations:
self,
cursor: Union[SQLiteCursorWrapper, CursorDebugWrapper],
sql: str,
params: Optional[Union[Tuple, List[str]]]
params: Optional[Union[List[str], Tuple]]
) -> str: ...
def no_limit_value(self) -> int: ...
def pk_default_value(self) -> str: ...
@@ -108,7 +116,7 @@ class DatabaseOperations:
self,
internal_type: str,
lhs: Tuple[str, List[Any]],
rhs: Union[Tuple[str, List[Any]], Tuple[str, List[str]]]
) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
rhs: Union[Tuple[str, List[str]], Tuple[str, List[Any]]]
) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
def time_extract_sql(self, lookup_type: str, field_name: str) -> str: ...
def time_trunc_sql(self, lookup_type: str, field_name: str) -> str: ...

View File

@@ -20,13 +20,13 @@ class DatabaseSchemaEditor:
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def _alter_field(
self,
model: Any,
model: Type[Model],
old_field: Field,
new_field: Field,
old_type: str,
new_type: str,
old_db_params: Dict[str, Union[str, None]],
new_db_params: Dict[str, Union[str, None]],
old_db_params: Dict[str, Optional[str]],
new_db_params: Dict[str, Optional[str]],
strict: bool = ...
) -> None: ...
def _is_referenced_by_fk_constraint(
@@ -37,7 +37,7 @@ class DatabaseSchemaEditor:
) -> bool: ...
def _remake_table(
self,
model: Any,
model: Type[Model],
create_field: Optional[Union[IntegerField, TimeField]] = ...,
delete_field: Optional[Union[AutoField, SlugField]] = ...,
alter_field: Any = ...
@@ -45,18 +45,18 @@ class DatabaseSchemaEditor:
def add_field(self, model: Type[Model], field: Field) -> None: ...
def alter_db_table(
self,
model: Any,
model: Type[Model],
old_db_table: str,
new_db_table: str,
disable_constraints: bool = ...
) -> None: ...
def alter_field(
self,
model: Any,
model: Type[Model],
old_field: Field,
new_field: Field,
strict: bool = ...
) -> None: ...
def delete_model(self, model: Any, handle_autom2m: bool = ...) -> None: ...
def delete_model(self, model: Type[Model], handle_autom2m: bool = ...) -> None: ...
def quote_value(self, value: Optional[Union[int, memoryview, str]]) -> str: ...
def remove_field(self, model: Type[Model], field: Field) -> None: ...

View File

@@ -47,7 +47,7 @@ def typecast_timestamp(s: str) -> date: ...
class CursorDebugWrapper:
def execute(self, sql: str, params: Optional[Union[Tuple, List[str]]] = ...): ...
def execute(self, sql: str, params: Optional[Union[List[str], Tuple]] = ...): ...
class CursorWrapper:

View File

@@ -1,12 +1,13 @@
from django.db.migrations.graph import MigrationGraph
from django.db.migrations.migration import Migration
from django.db.migrations.operations.base import Operation
from django.db.migrations.operations.fields import FieldOperation
from django.db.migrations.operations.models import (
AddIndex,
CreateModel,
DeleteModel,
FieldRelatedOptionOperation,
ModelOperation,
RemoveIndex,
)
from django.db.migrations.questioner import MigrationQuestioner
from django.db.migrations.state import ProjectState
@@ -62,7 +63,7 @@ class MigrationAutodetector:
def add_operation(
self,
app_label: str,
operation: Operation,
operation: Union[FieldOperation, RemoveIndex, ModelOperation],
dependencies: Any = ...,
beginning: bool = ...
) -> None: ...
@@ -81,11 +82,11 @@ class MigrationAutodetector:
) -> Dict[str, List[Migration]]: ...
def check_dependency(
self,
operation: Operation,
dependency: Union[Tuple[str, str, str, str], Tuple[str, str, str, bool], Tuple[str, str, None, bool]]
operation: Union[FieldOperation, AddIndex, ModelOperation],
dependency: Union[Tuple[str, str, None, bool], Tuple[str, str, str, str], Tuple[str, str, str, bool]]
) -> bool: ...
def create_altered_indexes(self) -> None: ...
def deep_deconstruct(self, obj: Any) -> Any: ...
def deep_deconstruct(self, obj: object) -> Any: ...
def generate_added_fields(self) -> None: ...
def generate_added_indexes(self) -> None: ...
def generate_altered_db_table(self) -> None: ...

View File

@@ -20,12 +20,17 @@ class MigrationExecutor:
progress_callback: Optional[Callable] = ...
) -> None: ...
def _create_project_state(self, with_applied_migrations: bool = ...) -> ProjectState: ...
def _migrate_all_backwards(self, plan: Any, full_plan: Any, fake: bool) -> ProjectState: ...
def _migrate_all_backwards(
self,
plan: List[Tuple[Migration, bool]],
full_plan: Union[List[Any], List[Tuple[Migration, bool]]],
fake: bool
) -> ProjectState: ...
def _migrate_all_forwards(
self,
state: ProjectState,
plan: Any,
full_plan: Any,
plan: Union[List[Any], List[Tuple[Migration, bool]]],
full_plan: Union[List[Any], List[Tuple[Migration, bool]]],
fake: bool,
fake_initial: bool
) -> ProjectState: ...
@@ -44,17 +49,17 @@ class MigrationExecutor:
) -> Tuple[bool, ProjectState]: ...
def migrate(
self,
targets: Optional[Union[List[Tuple[str, str]], List[Tuple[str, None]]]],
plan: Any = ...,
targets: Optional[Union[List[Tuple[str, None]], List[Tuple[str, str]]]],
plan: Optional[Union[List[Any], List[Tuple[Migration, bool]]]] = ...,
state: Optional[ProjectState] = ...,
fake: bool = ...,
fake_initial: bool = ...
) -> ProjectState: ...
def migration_plan(
self,
targets: Union[Set[Tuple[str, str]], List[Tuple[str, str]], List[Tuple[str, None]]],
targets: Union[List[Tuple[str, None]], List[Tuple[str, str]], Set[Tuple[str, str]]],
clean_start: bool = ...
) -> Any: ...
) -> Union[List[Any], List[Tuple[Migration, bool]], List[Tuple[object, bool]]]: ...
def unapply_migration(
self,
state: ProjectState,

View File

@@ -1,7 +1,9 @@
from django.db.migrations.migration import SwappableTuple
from django.db.migrations.migration import (
Migration,
SwappableTuple,
)
from django.db.migrations.state import ProjectState
from typing import (
Any,
Callable,
List,
Optional,
@@ -11,7 +13,12 @@ from typing import (
class DummyNode:
def __init__(self, key: Tuple[str, str], origin: Any, error_message: str) -> None: ...
def __init__(
self,
key: Tuple[str, str],
origin: Union[Migration, str],
error_message: str
) -> None: ...
def promote(self) -> None: ...
def raise_error(self): ...
@@ -25,14 +32,19 @@ class MigrationGraph:
def _nodes_and_edges(self) -> Tuple[int, int]: ...
def add_dependency(
self,
migration: Any,
migration: Optional[Union[Migration, str]],
child: Tuple[str, str],
parent: Tuple[str, str],
skip_validation: bool = ...
) -> None: ...
def add_dummy_node(self, key: Tuple[str, str], origin: Any, error_message: str) -> None: ...
def add_node(self, key: Tuple[str, str], migration: Any) -> None: ...
def backwards_plan(self, target: Union[Tuple[str, str], Node]) -> List[Tuple[str, str]]: ...
def add_dummy_node(
self,
key: Tuple[str, str],
origin: Union[Migration, str],
error_message: str
) -> None: ...
def add_node(self, key: Tuple[str, str], migration: object) -> None: ...
def backwards_plan(self, target: Union[Node, Tuple[str, str]]) -> List[Tuple[str, str]]: ...
def clear_cache(self) -> None: ...
def ensure_not_cyclic(
self,

View File

@@ -4,13 +4,18 @@ from typing import (
List,
Optional,
Tuple,
Type,
Union,
)
class Operation:
@staticmethod
def __new__(cls: Any, *args, **kwargs) -> Operation: ...
def __new__(
cls: Type[Operation],
*args,
**kwargs
) -> Operation: ...
def _get_model_tuple(self, remote_model: str, app_label: str, model_name: str) -> Tuple[str, str]: ...
def reduce(
self,

View File

@@ -1,8 +1,10 @@
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.migrations.operations.base import Operation
from django.db.migrations.operations.models import (
AlterUniqueTogether,
CreateModel,
DeleteModel,
FieldRelatedOptionOperation,
ModelOperation,
)
from django.db.migrations.state import ProjectState
from django.db.models.fields import (
@@ -47,7 +49,7 @@ class AddField:
def describe(self) -> str: ...
def reduce(
self,
operation: Operation,
operation: Union[FieldOperation, CreateModel, FieldRelatedOptionOperation],
in_between: List[AddField],
app_label: Optional[str] = ...
) -> Union[bool, List[AddField]]: ...
@@ -82,7 +84,7 @@ class AlterField:
def describe(self) -> str: ...
def reduce(
self,
operation: Union[DeleteModel, AlterField, AlterUniqueTogether],
operation: Union[AlterField, DeleteModel, AlterUniqueTogether],
in_between: List[Any],
app_label: str = ...
) -> bool: ...
@@ -99,7 +101,7 @@ class FieldOperation:
def name_lower(self) -> str: ...
def reduce(
self,
operation: Operation,
operation: Union[ModelOperation, FieldOperation],
in_between: Any,
app_label: str = ...
) -> bool: ...

View File

@@ -1,5 +1,6 @@
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.migrations.operations.base import Operation
from django.db.migrations.operations.fields import FieldOperation
from django.db.migrations.state import ProjectState
from django.db.models.indexes import Index
from typing import (
@@ -183,7 +184,7 @@ class DeleteModel:
class FieldRelatedOptionOperation:
def reduce(
self,
operation: Operation,
operation: Union[FieldOperation, CreateModel, AlterIndexTogether],
in_between: List[DeleteModel],
app_label: Optional[str] = ...
) -> Any: ...
@@ -200,7 +201,7 @@ class ModelOperation:
def name_lower(self) -> str: ...
def reduce(
self,
operation: Operation,
operation: Union[FieldOperation, ModelOperation],
in_between: Any,
app_label: Optional[str] = ...
) -> bool: ...
@@ -210,7 +211,7 @@ class ModelOperation:
class ModelOptionOperation:
def reduce(
self,
operation: Operation,
operation: Union[FieldOperation, CreateModel, FieldRelatedOptionOperation],
in_between: List[DeleteModel],
app_label: Optional[str] = ...
) -> Union[bool, List[AlterUniqueTogether]]: ...

View File

@@ -77,7 +77,7 @@ class SeparateDatabaseAndState:
def __init__(
self,
database_operations: List[ModelOperation] = ...,
state_operations: Union[List[AddField], List[CreateModel], List[ModelOperation]] = ...
state_operations: Union[List[CreateModel], List[AddField], List[ModelOperation]] = ...
) -> None: ...
def database_forwards(
self,

View File

@@ -12,7 +12,7 @@ def serializer_factory(value: Any) -> BaseSerializer: ...
class BaseSequenceSerializer:
def serialize(self) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ...
def serialize(self) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ...
class BaseSerializer:
@@ -38,8 +38,8 @@ class DeconstructableSerializer:
@staticmethod
def serialize_deconstructed(
path: str,
args: Union[Tuple, List[str]],
kwargs: Dict[str, Any]
args: Union[List[str], Tuple],
kwargs: Dict[str, object]
) -> Tuple[str, Set[str]]: ...
@@ -96,7 +96,7 @@ class TupleSerializer:
class TypeSerializer:
def serialize(self) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ...
def serialize(self) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ...
class UUIDSerializer:

View File

@@ -1,9 +1,11 @@
from django.apps.registry import Apps
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.indexes import Index
from typing import (
Any,
Iterator,
Type,
)
@@ -27,7 +29,11 @@ class ModelState:
def clone(self) -> ModelState: ...
def construct_managers(self) -> Iterator[Any]: ...
@classmethod
def from_model(cls, model: Any, exclude_rels: bool = ...) -> ModelState: ...
def from_model(
cls,
model: Type[Model],
exclude_rels: bool = ...
) -> ModelState: ...
def get_field_by_name(self, name: str) -> Field: ...
def get_index_by_name(self, name: str) -> Index: ...
@cached_property

View File

@@ -19,7 +19,7 @@ class MigrationWriter:
@property
def path(self) -> str: ...
@classmethod
def serialize(cls, value: Any) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ...
def serialize(cls, value: Any) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ...
class OperationWriter:
@@ -27,7 +27,7 @@ class OperationWriter:
def feed(self, line: str) -> None: ...
def indent(self) -> None: ...
def render(self) -> str: ...
def serialize(self) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ...
def serialize(self) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ...
def unindent(self) -> None: ...

View File

@@ -1,3 +1,8 @@
from django.contrib.auth.models import (
Permission,
User,
)
from django.contrib.contenttypes.models import ContentType
from django.db.models.base import Model
from django.db.models.fields.related import ForeignKey
from django.db.models.fields.reverse_related import ManyToOneRel
@@ -11,6 +16,7 @@ from typing import (
List,
Optional,
Tuple,
Type,
Union,
)
@@ -50,7 +56,7 @@ class Collector:
def add(
self,
objs: Any,
source: Any = ...,
source: Optional[Union[Type[Model], Type[ContentType]]] = ...,
nullable: bool = ...,
reverse_dependency: bool = ...
) -> Any: ...
@@ -68,15 +74,19 @@ class Collector:
def collect(
self,
objs: Any,
source: Any = ...,
source: Optional[Union[Type[Model], Type[ContentType]]] = ...,
nullable: bool = ...,
collect_related: bool = ...,
source_attr: Optional[str] = ...,
reverse_dependency: bool = ...,
keep_parents: bool = ...
) -> None: ...
def delete(self) -> Union[Tuple[int, Dict[Any, Any]], Tuple[int, Dict[str, int]]]: ...
def get_del_batches(self, objs: Any, field: ForeignKey) -> Any: ...
def delete(self) -> Union[Tuple[int, Dict[str, int]], Tuple[int, Dict[Any, Any]]]: ...
def get_del_batches(
self,
objs: Union[List[User], List[Model], List[ContentType], List[Permission]],
field: ForeignKey
) -> Union[List[List[Model]], List[List[ContentType]], List[List[User]], List[List[Permission]]]: ...
def instances_with_model(self) -> Iterator[Any]: ...
def related_objects(
self,
@@ -90,5 +100,5 @@ class ProtectedError:
def __init__(
self,
msg: str,
protected_objects: Union[QuerySet, List[Model]]
protected_objects: Union[List[Model], QuerySet]
) -> None: ...

View File

@@ -4,10 +4,19 @@ from datetime import (
timedelta,
)
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.aggregates import Count
from django.db.models.fields import Field
from django.db.models.aggregates import (
Aggregate,
Count,
)
from django.db.models.fields import (
DateTimeCheckMixin,
Field,
)
from django.db.models.fields.related import ForeignKey
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.fields.reverse_related import (
ForeignObjectRel,
OneToOneRel,
)
from django.db.models.functions.datetime import Trunc
from django.db.models.functions.text import BytesToCharFieldConversionMixin
from django.db.models.query_utils import Q
@@ -42,10 +51,17 @@ class BaseExpression:
connection: DatabaseWrapper
) -> str: ...
@cached_property
def _output_field_or_none(self) -> Any: ...
def _output_field_or_none(
self
) -> Optional[Union[Field, DateTimeCheckMixin]]: ...
def _parse_expressions(self, *expressions) -> Any: ...
def _prepare(self, field: Any) -> Expression: ...
def _resolve_output_field(self) -> Any: ...
def _prepare(
self,
field: Union[Field, DateTimeCheckMixin, reverse_related.OneToOneRel]
) -> Expression: ...
def _resolve_output_field(
self
) -> Optional[Union[Field, DateTimeCheckMixin]]: ...
def asc(self, **kwargs) -> OrderBy: ...
@cached_property
def contains_aggregate(self) -> bool: ...
@@ -55,21 +71,25 @@ class BaseExpression:
def contains_over_clause(self) -> bool: ...
@cached_property
def convert_value(self) -> Callable: ...
def copy(self) -> BaseExpression: ...
def copy(
self
) -> Union[OrderBy, Expression, SQLiteNumericMixin]: ...
def desc(self, **kwargs) -> OrderBy: ...
@property
def field(self) -> Any: ...
def field(
self
) -> Union[ForeignObjectRel, Field, DateTimeCheckMixin]: ...
def flatten(self) -> Iterator[Union[Value, Func]]: ...
def get_db_converters(self, connection: DatabaseWrapper) -> List[Callable]: ...
def get_group_by_cols(
self
) -> Union[List[CombinedExpression], List[Trunc], List[Col]]: ...
def get_lookup(self, lookup: str) -> Any: ...
def get_lookup(self, lookup: str) -> object: ...
def get_source_expressions(self) -> List[Any]: ...
def get_source_fields(self) -> Any: ...
def get_transform(self, name: str) -> Any: ...
@cached_property
def output_field(self) -> Field: ...
def output_field(self) -> Union[Field, DateTimeCheckMixin]: ...
def relabeled_clone(
self,
change_map: Union[OrderedDict, Dict[Union[str, None], str]]
@@ -81,7 +101,7 @@ class BaseExpression:
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...
) -> BaseExpression: ...
) -> Union[OrderBy, Expression]: ...
def set_source_expressions(self, exprs: List[Any]) -> None: ...
@@ -110,7 +130,12 @@ class Case:
class Col:
def __init__(self, alias: str, target: Field, output_field: Any = ...) -> None: ...
def __init__(
self,
alias: str,
target: Union[Field, DateTimeCheckMixin],
output_field: Optional[Union[reverse_related.ForeignObjectRel, Field]] = ...
) -> None: ...
def __repr__(self) -> str: ...
def as_sql(
self,
@@ -126,7 +151,10 @@ class Col:
class Combinable:
def __add__(self, other: Any) -> CombinedExpression: ...
def __add__(
self,
other: Union[float, timedelta, F, Aggregate]
) -> CombinedExpression: ...
def __mod__(self, other: int) -> CombinedExpression: ...
def __mul__(
self,
@@ -134,16 +162,16 @@ class Combinable:
) -> CombinedExpression: ...
def __radd__(
self,
other: Optional[Union[float, int, timedelta]]
other: Optional[Union[float, timedelta]]
) -> CombinedExpression: ...
def __rand__(self, other: object): ...
def __rmul__(self, other: float) -> CombinedExpression: ...
def __ror__(self, other: object): ...
def __rsub__(self, other: Union[float, int]) -> CombinedExpression: ...
def __rsub__(self, other: float) -> CombinedExpression: ...
def __rtruediv__(self, other: int) -> CombinedExpression: ...
def __sub__(
self,
other: Union[float, timedelta, int, F]
other: Union[float, timedelta, F]
) -> CombinedExpression: ...
def __truediv__(
self,
@@ -158,7 +186,7 @@ class CombinedExpression:
self,
lhs: Combinable,
connector: str,
rhs: Combinable,
rhs: Union[F, Expression],
output_field: None = ...
) -> None: ...
def __str__(self) -> str: ...
@@ -166,7 +194,7 @@ class CombinedExpression:
self,
compiler: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[datetime]], Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[float]]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[float]], Tuple[str, List[Any]], Tuple[str, List[datetime]]]: ...
def get_source_expressions(self) -> Any: ...
def resolve_expression(
self,
@@ -209,7 +237,7 @@ class Exists:
connection: DatabaseWrapper,
template: None = ...,
**extra_context
) -> Union[Tuple[str, Tuple[int]], Tuple[str, Tuple]]: ...
) -> Union[Tuple[str, Tuple], Tuple[str, Tuple[int]]]: ...
def resolve_expression(
self,
query: Query = ...,
@@ -236,10 +264,10 @@ class ExpressionWrapper:
) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]]]: ...
def get_source_expressions(
self
) -> Union[List[Q], List[CombinedExpression], List[WhereNode]]: ...
) -> Union[List[CombinedExpression], List[Q], List[WhereNode]]: ...
def set_source_expressions(
self,
exprs: Union[List[WhereNode], List[CombinedExpression]]
exprs: Union[List[CombinedExpression], List[WhereNode]]
) -> None: ...
@@ -289,7 +317,7 @@ class Func:
class OrderBy:
def __init__(
self,
expression: Combinable,
expression: Union[F, Expression],
descending: bool = ...,
nulls_first: bool = ...,
nulls_last: bool = ...

View File

@@ -19,6 +19,7 @@ from typing import (
Any,
List,
Optional,
Type,
Union,
)
@@ -27,7 +28,7 @@ class AutoField:
def __init__(self, *args, **kwargs) -> None: ...
def _check_primary_key(self) -> List[Any]: ...
def check(self, **kwargs) -> List[Any]: ...
def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ...
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ...
def deconstruct(self) -> Any: ...
def formfield(self, **kwargs) -> None: ...
def get_db_prep_value(
@@ -86,7 +87,7 @@ class CharField:
def check(self, **kwargs) -> List[Error]: ...
def formfield(self, **kwargs) -> Union[CharField, TypedChoiceField]: ...
def get_internal_type(self) -> str: ...
def get_prep_value(self, value: Any) -> object: ...
def get_prep_value(self, value: object) -> object: ...
def to_python(self, value: Optional[Union[int, str, Model]]) -> Optional[str]: ...
@@ -100,15 +101,15 @@ class DateField:
**kwargs
) -> None: ...
def _check_fix_default_value(self) -> List[Warning]: ...
def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ...
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ...
def deconstruct(self) -> Any: ...
def formfield(
self,
**kwargs
) -> Union[SplitDateTimeField, BaseTemporalField]: ...
) -> Union[BaseTemporalField, SplitDateTimeField]: ...
def get_db_prep_value(
self,
value: Optional[Union[date, str]],
value: Optional[Union[str, date]],
connection: DatabaseWrapper,
prepared: bool = ...
) -> Optional[str]: ...

View File

@@ -18,13 +18,14 @@ from typing import (
List,
Optional,
Tuple,
Type,
Union,
)
class FieldFile:
def __eq__(self, other: Optional[Union[Tuple, str, FieldFile]]) -> bool: ...
def __getstate__(self) -> Dict[str, Union[str, bool, None]]: ...
def __eq__(self, other: Optional[Union[str, Tuple, FieldFile]]) -> bool: ...
def __getstate__(self) -> Dict[str, Optional[Union[str, bool]]]: ...
def __init__(
self,
instance: Model,
@@ -51,8 +52,8 @@ class FieldFile:
class FileDescriptor:
def __get__(
self,
instance: Any,
cls: Any = ...
instance: Optional[Model],
cls: Type[Model] = ...
) -> Union[FileDescriptor, FieldFile]: ...
def __init__(self, field: FileField) -> None: ...
def __set__(
@@ -74,10 +75,10 @@ class FileField:
def _check_primary_key(self) -> List[Error]: ...
def _check_upload_to(self) -> List[Any]: ...
def check(self, **kwargs) -> List[Any]: ...
def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ...
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ...
def deconstruct(self) -> Any: ...
def formfield(self, **kwargs) -> FileField: ...
def generate_filename(self, instance: Any, filename: str) -> str: ...
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
def get_internal_type(self) -> str: ...
def get_prep_value(self, value: FieldFile) -> str: ...
def pre_save(

View File

@@ -1,9 +1,17 @@
from django.db.models.base import Model
from typing import Any
from typing import Optional
class FieldCacheMixin:
def delete_cached_value(self, instance: Model) -> None: ...
def get_cached_value(self, instance: Model, default: object = ...) -> Any: ...
def get_cached_value(
self,
instance: Model,
default: object = ...
) -> Optional[Model]: ...
def is_cached(self, instance: Model) -> bool: ...
def set_cached_value(self, instance: Model, value: Any) -> None: ...
def set_cached_value(
self,
instance: Model,
value: Optional[Model]
) -> None: ...

View File

@@ -3,11 +3,13 @@ from django.core.checks.messages import (
Warning,
)
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.expressions import Col
from django.db.models.fields import Field
from django.db.models.fields.reverse_related import (
ForeignObjectRel,
ManyToOneRel,
OneToOneRel,
)
from django.db.models.query_utils import (
FilteredRelation,
@@ -21,6 +23,7 @@ from typing import (
List,
Optional,
Tuple,
Type,
Union,
)
from uuid import UUID
@@ -44,10 +47,10 @@ class ForeignKey:
def check(
self,
**kwargs
) -> Union[List[Error], List[Warning]]: ...
) -> Union[List[Warning], List[Error]]: ...
def contribute_to_related_class(
self,
cls: Any,
cls: Type[Model],
related: ManyToOneRel
) -> None: ...
def db_check(self, connection: DatabaseWrapper) -> List[Any]: ...
@@ -57,16 +60,20 @@ class ForeignKey:
def formfield(self, *, using = ..., **kwargs) -> ModelChoiceField: ...
def get_attname(self) -> str: ...
def get_attname_column(self) -> Tuple[str, str]: ...
def get_col(self, alias: str, output_field: Any = ...) -> Col: ...
def get_col(
self,
alias: str,
output_field: Optional[Union[Field, reverse_related.OneToOneRel]] = ...
) -> Col: ...
def get_db_converters(self, connection: DatabaseWrapper) -> List[Any]: ...
def get_db_prep_save(
self,
value: Any,
value: object,
connection: DatabaseWrapper
) -> Optional[Union[str, int]]: ...
def get_db_prep_value(
self,
value: Union[str, UUID, int],
value: Union[str, int, UUID],
connection: DatabaseWrapper,
prepared: bool = ...
) -> Union[str, int]: ...
@@ -78,7 +85,7 @@ class ForeignKey:
@property
def target_field(self) -> Field: ...
def to_python(self, value: Union[str, int]) -> Union[str, int]: ...
def validate(self, value: int, model_instance: Any) -> None: ...
def validate(self, value: int, model_instance: Optional[Model]) -> None: ...
class ForeignObject:
@@ -86,8 +93,8 @@ class ForeignObject:
self,
to: Any,
on_delete: Callable,
from_fields: Union[Tuple[str, str], List[str]],
to_fields: Union[List[str], List[None], Tuple[str, str]],
from_fields: Union[List[str], Tuple[str, str]],
to_fields: Union[List[None], List[str], Tuple[str, str]],
rel: Optional[ForeignObjectRel] = ...,
related_name: Optional[str] = ...,
related_query_name: None = ...,

View File

@@ -1,5 +1,6 @@
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.base import Model
from django.db.models.expressions import F
from django.db.models.fields.related import ForeignObject
from django.db.models.fields.reverse_related import (
ForeignObjectRel,
@@ -8,24 +9,33 @@ from django.db.models.fields.reverse_related import (
)
from django.db.models.query import QuerySet
from typing import (
Any,
Callable,
List,
Optional,
Tuple,
Type,
Union,
)
class ForwardManyToOneDescriptor:
@cached_property
def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ...
def __get__(self, instance: Any, cls: Any = ...) -> Any: ...
def __get__(
self,
instance: Optional[Model],
cls: Type[Model] = ...
) -> Optional[Union[Model, ForwardManyToOneDescriptor]]: ...
def __init__(self, field_with_rel: ForeignObject) -> None: ...
def __set__(self, instance: Model, value: Any) -> None: ...
def __set__(
self,
instance: Model,
value: Optional[Union[Model, F]]
) -> None: ...
def get_object(self, instance: Model) -> Model: ...
def get_prefetch_queryset(
self,
instances: Any,
instances: List[Model],
queryset: Optional[QuerySet] = ...
) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ...
def get_queryset(self, **hints) -> QuerySet: ...
@@ -33,7 +43,7 @@ class ForwardManyToOneDescriptor:
class ForwardOneToOneDescriptor:
def __set__(self, instance: Model, value: Any) -> None: ...
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
def get_object(self, instance: Model) -> Model: ...
@@ -45,7 +55,7 @@ class ReverseManyToOneDescriptor:
def __get__(
self,
instance: Optional[Model],
cls: Any = ...
cls: Type[Model] = ...
) -> ReverseManyToOneDescriptor: ...
def __init__(self, rel: ForeignObjectRel) -> None: ...
def _get_set_deprecation_msg_params(self) -> Tuple[str, str]: ...
@@ -54,7 +64,11 @@ class ReverseManyToOneDescriptor:
class ReverseOneToOneDescriptor:
@cached_property
def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ...
def __get__(self, instance: Any, cls: Any = ...) -> Any: ...
def __get__(
self,
instance: Optional[Model],
cls: Type[Model] = ...
) -> Union[Model, ReverseOneToOneDescriptor]: ...
def __init__(self, related: OneToOneRel) -> None: ...
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
def get_queryset(self, **hints) -> QuerySet: ...

View File

@@ -32,13 +32,13 @@ class MultiColSource:
self,
alias: str,
targets: Union[Tuple[IntegerField, related.ForeignKey], Tuple[IntegerField, IntegerField]],
sources: Union[Tuple[AutoField, IntegerField], Tuple[IntegerField, AutoField]],
sources: Union[Tuple[IntegerField, AutoField], Tuple[AutoField, IntegerField]],
field: related.ForeignObject
) -> None: ...
def get_lookup(
self,
lookup: str
) -> Type[Union[RelatedIn, RelatedExact]]: ...
) -> Type[Union[RelatedExact, RelatedIn]]: ...
def relabeled_clone(
self,
relabels: OrderedDict
@@ -50,8 +50,8 @@ class RelatedIn:
self,
compiler: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
def get_prep_lookup(self) -> Union[List[UUID], Query, List[int], List[str]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
def get_prep_lookup(self) -> Union[Query, List[int], List[UUID], List[str]]: ...
class RelatedLookupMixin:
@@ -59,5 +59,5 @@ class RelatedLookupMixin:
self,
compiler: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
def get_prep_lookup(self) -> Any: ...

View File

@@ -44,7 +44,7 @@ class ForeignObjectRel:
def __repr__(self) -> str: ...
@property
def db_type(self) -> Callable: ...
def get_accessor_name(self, model: Any = ...) -> Optional[str]: ...
def get_accessor_name(self, model: Optional[Type[Model]] = ...) -> Optional[str]: ...
def get_cache_name(self) -> str: ...
def get_choices(
self,
@@ -62,7 +62,7 @@ class ForeignObjectRel:
def get_lookup(
self,
lookup_name: str
) -> Type[Union[RelatedIsNull, RelatedIn, RelatedExact]]: ...
) -> Type[Union[RelatedIsNull, RelatedExact, RelatedIn]]: ...
def get_path_info(
self,
filtered_relation: Optional[FilteredRelation] = ...
@@ -81,7 +81,7 @@ class ForeignObjectRel:
@cached_property
def one_to_one(self) -> bool: ...
@cached_property
def related_model(self) -> Any: ...
def related_model(self) -> Type[Model]: ...
@property
def remote_field(
self

View File

@@ -35,7 +35,7 @@ class Concat:
def __init__(self, *expressions, **extra) -> None: ...
def _paired(
self,
expressions: Union[Tuple[Value, str], Tuple[str, str], Tuple[Value, str, Value]]
expressions: Union[Tuple[Value, str, Value], Tuple[Value, str], Tuple[str, str]]
) -> ConcatPair: ...
@@ -75,7 +75,7 @@ class Ord:
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context
) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
class Replace:

View File

@@ -7,6 +7,7 @@ from django.db.models.expressions import (
Expression,
Ref,
)
from django.db.models.fields.related_lookups import MultiColSource
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
from django.utils.datastructures import OrderedSet
@@ -34,7 +35,7 @@ class BuiltinLookup:
compiler: SQLCompiler,
connection: DatabaseWrapper,
lhs: Optional[Col] = ...
) -> Union[Tuple[str, List[str]], Tuple[str, List[int]], Tuple[str, List[Union[str, int]]], Tuple[str, List[Any]]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[Union[str, int]]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
class Exact:
@@ -64,11 +65,11 @@ class FieldGetDbPrepValueIterableMixin:
connection: DatabaseWrapper,
sql: str,
param: Any
) -> Union[Tuple[str, List[None]], Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
) -> Union[Tuple[str, List[None]], Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
class FieldGetDbPrepValueMixin:
def get_db_prep_lookup(self, value: Any, connection: DatabaseWrapper) -> Any: ...
def get_db_prep_lookup(self, value: object, connection: DatabaseWrapper) -> Any: ...
class IExact:
@@ -76,7 +77,7 @@ class IExact:
self,
qn: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
class In:
@@ -108,7 +109,11 @@ class IsNull:
class Lookup:
def __init__(self, lhs: Any, rhs: Any) -> None: ...
def __init__(
self,
lhs: Union[MultiColSource, Expression],
rhs: object
) -> None: ...
def apply_bilateral_transforms(
self,
value: Expression
@@ -130,7 +135,7 @@ class Lookup:
) -> Union[Tuple[str, List[int]], Tuple[str, List[SafeText]], Tuple[str, List[str]]]: ...
def get_group_by_cols(
self
) -> Union[List[Col], List[CombinedExpression]]: ...
) -> Union[List[CombinedExpression], List[Col]]: ...
def get_prep_lookup(self) -> Any: ...
def get_source_expressions(self) -> List[Col]: ...
def process_lhs(
@@ -147,7 +152,7 @@ class Lookup:
def relabeled_clone(
self,
relabels: Union[OrderedDict, Dict[str, str], Dict[Union[str, None], str]]
) -> BuiltinLookup: ...
) -> Union[IsNull, StartsWith, FieldGetDbPrepValueMixin, IContains]: ...
def rhs_is_direct_value(self) -> bool: ...
def set_source_expressions(self, new_exprs: List[Ref]) -> None: ...
@@ -158,7 +163,7 @@ class PatternLookup:
self,
qn: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[str]], Tuple[str, List[int]], Tuple[str, List[Any]]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
class Range:
@@ -194,7 +199,7 @@ class YearExact:
self,
compiler: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
class YearGt:

View File

@@ -1,3 +1,5 @@
from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import Permission
from django.db.models.base import Model
from django.db.models.query import QuerySet
from typing import (
@@ -16,16 +18,20 @@ class BaseManager:
def __eq__(self, other: Optional[Manager]) -> bool: ...
def __init__(self) -> None: ...
@staticmethod
def __new__(cls: Any, *args, **kwargs) -> Manager: ...
def __new__(cls: Type[Manager], *args, **kwargs) -> Manager: ...
@classmethod
def _get_queryset_methods(cls, queryset_class: Any) -> Dict[str, Callable]: ...
def _get_queryset_methods(cls, queryset_class: Type[QuerySet]) -> Dict[str, Callable]: ...
def _set_creation_counter(self) -> None: ...
def all(self) -> QuerySet: ...
def check(self, **kwargs) -> List[Any]: ...
def contribute_to_class(self, model: Any, name: str) -> None: ...
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
@property
def db(self) -> str: ...
def db_manager(self, using: Optional[str] = ..., hints: Any = ...) -> Manager: ...
def db_manager(
self,
using: Optional[str] = ...,
hints: Optional[Union[Dict[str, Model], Dict[str, LogEntry], Dict[str, Permission]]] = ...
) -> Manager: ...
def deconstruct(
self
) -> Union[Tuple[bool, str, None, Tuple[str, str, int, int], Dict[Any, Any]], Tuple[bool, str, None, Tuple, Dict[Any, Any]]]: ...

View File

@@ -1,7 +1,17 @@
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db.models.base import Model
from django.db.models.fields import (
DateTimeCheckMixin,
Field,
)
from django.utils.datastructures import ImmutableList
from typing import (
Any,
Dict,
Optional,
Set,
Type,
Union,
)
@@ -11,14 +21,16 @@ class Options:
def __str__(self) -> str: ...
def _expire_cache(self, forward: bool = ..., reverse: bool = ...) -> None: ...
@cached_property
def _forward_fields_map(self) -> Dict[str, Any]: ...
def _forward_fields_map(
self
) -> Dict[str, Union[GenericForeignKey, Field, DateTimeCheckMixin]]: ...
def _get_fields(
self,
forward: bool = ...,
reverse: bool = ...,
include_parents: object = ...,
include_hidden: bool = ...,
seen_models: Any = ...
seen_models: Optional[Set[Type[Model]]] = ...
) -> ImmutableList: ...
def _populate_directed_relation_graph(self) -> Any: ...
def _prepare(self, model: Any) -> None: ...
def _prepare(self, model: Type[Model]) -> None: ...

View File

@@ -6,6 +6,7 @@ from typing import (
Iterator,
Optional,
Tuple,
Type,
Union,
)
@@ -37,7 +38,7 @@ class NamedValuesListIterable:
class Prefetch:
def __eq__(self, other: None) -> bool: ...
def __getstate__(self) -> Dict[str, Union[str, QuerySet, None]]: ...
def __getstate__(self) -> Dict[str, Optional[Union[str, QuerySet]]]: ...
def __hash__(self) -> int: ...
def __init__(
self,
@@ -58,7 +59,7 @@ class QuerySet:
def __getstate__(self) -> Dict[str, Any]: ...
def __init__(
self,
model: Any = ...,
model: Type[Model] = ...,
query: Optional[Query] = ...,
using: Optional[str] = ...,
hints: Dict[str, Model] = ...

View File

@@ -2,9 +2,16 @@ from collections import OrderedDict
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.expressions import F
from django.db.models.fields import Field
from django.db.models.fields import (
DateTimeCheckMixin,
Field,
)
from django.db.models.fields.related import ForeignKey
from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.lookups import (
Lookup,
Transform,
)
from django.db.models.options import Options
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
@@ -17,12 +24,13 @@ from typing import (
Optional,
Set,
Tuple,
Type,
Union,
)
def check_rel_lookup_compatibility(
model: Any,
model: Type[Model],
target_opts: Options,
field: Union[ManyToOneRel, ForeignKey]
) -> bool: ...
@@ -32,7 +40,7 @@ def refs_expression(lookup_parts: List[str], annotations: OrderedDict) -> Any: .
def select_related_descend(
field: Field,
field: Union[Field, DateTimeCheckMixin],
restricted: bool,
requested: Any,
load_fields: Optional[Set[str]],
@@ -40,15 +48,17 @@ def select_related_descend(
) -> bool: ...
def subclasses(cls: Any) -> Iterator[Any]: ...
def subclasses(
cls: Type[Union[Field, Transform]]
) -> Iterator[Type[Union[Field, Transform]]]: ...
class DeferredAttribute:
def __get__(
self,
instance: Any,
cls: Any = ...
) -> Optional[Union[DeferredAttribute, str, int]]: ...
instance: Optional[Model],
cls: Type[Model] = ...
) -> Optional[Union[str, int, DeferredAttribute]]: ...
def __init__(self, field_name: str) -> None: ...
def _check_parent_chain(self, instance: Model, name: str) -> None: ...
@@ -60,7 +70,7 @@ class FilteredRelation:
self,
compiler: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[str]], Tuple[str, List[int]], Tuple[str, List[Union[int, str]]], Tuple[str, List[Any]]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]], Tuple[str, List[Union[int, str]]]]: ...
def clone(self) -> FilteredRelation: ...
@@ -72,7 +82,7 @@ class Q:
def _combine(self, other: Q, conn: str) -> Q: ...
def deconstruct(
self
) -> Union[Tuple[str, Tuple, Dict[str, F]], Tuple[str, Tuple[Tuple[str, F], Tuple[str, F]], Dict[Any, Any]], Tuple[str, Tuple[Q], Dict[Any, Any]]]: ...
) -> Union[Tuple[str, Tuple[Tuple[str, F], Tuple[str, F]], Dict[Any, Any]], Tuple[str, Tuple, Dict[str, F]], Tuple[str, Tuple[Q], Dict[Any, Any]]]: ...
def resolve_expression(
self,
query: Query = ...,
@@ -98,12 +108,22 @@ class RegisterLookupMixin:
@classmethod
def _get_lookup(cls, lookup_name: str) -> Any: ...
@classmethod
def _unregister_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> None: ...
def _unregister_lookup(
cls,
lookup: Type[Union[Lookup, Transform]],
lookup_name: Optional[str] = ...
) -> None: ...
def get_lookup(self, lookup_name: str) -> Any: ...
@classmethod
def get_lookups(cls) -> Dict[str, Any]: ...
def get_transform(self, lookup_name: str) -> Any: ...
def get_lookups(cls) -> Dict[str, Type[Union[Lookup, Transform]]]: ...
def get_transform(self, lookup_name: str) -> object: ...
@staticmethod
def merge_dicts(dicts: Any) -> Dict[str, Any]: ...
def merge_dicts(
dicts: Any
) -> Dict[str, Type[Union[Lookup, Transform]]]: ...
@classmethod
def register_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> Any: ...
def register_lookup(
cls,
lookup: Type[Union[Lookup, Transform]],
lookup_name: Optional[str] = ...
) -> Type[Union[Lookup, Transform]]: ...

View File

@@ -1,8 +1,12 @@
from django.apps.registry import Apps
from django.contrib.sites.models import Site
from django.db.models.base import Model
from typing import (
Any,
Callable,
Optional,
Type,
Union,
)
@@ -18,7 +22,7 @@ class ModelSignal:
def connect(
self,
receiver: Callable,
sender: Any = ...,
sender: Optional[Union[Type[Site], Type[Model]]] = ...,
weak: bool = ...,
dispatch_uid: None = ...,
apps: None = ...
@@ -26,7 +30,7 @@ class ModelSignal:
def disconnect(
self,
receiver: Callable = ...,
sender: Any = ...,
sender: Optional[Type[Model]] = ...,
dispatch_uid: None = ...,
apps: None = ...
) -> bool: ...

View File

@@ -1,5 +1,6 @@
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.backends.utils import CursorWrapper
from django.db.models.base import Model
from django.db.models.expressions import (
Col,
CombinedExpression,
@@ -21,6 +22,7 @@ from typing import (
Optional,
Set,
Tuple,
Type,
Union,
)
@@ -44,14 +46,14 @@ class SQLCompiler:
alias: str,
columns: List[str],
compiler: SQLCompiler
) -> Union[Tuple[str, Tuple[str]], Tuple[str, Tuple]]: ...
) -> Union[Tuple[str, Tuple], Tuple[str, Tuple[str]]]: ...
def collapse_group_by(
self,
expressions: Union[List[Col], List[Union[Col, Trunc]], List[Expression], List[Union[Col, CombinedExpression]]],
having: Union[List[Col], Tuple, List[CombinedExpression]]
) -> Union[List[Col], List[Union[Col, Trunc]], List[Expression], List[Union[Col, CombinedExpression]]]: ...
expressions: Union[List[Union[Col, CombinedExpression]], List[Expression], List[Col], List[Union[Col, Trunc]]],
having: Union[List[CombinedExpression], List[Col], Tuple]
) -> Union[List[Union[Col, CombinedExpression]], List[Expression], List[Col], List[Union[Col, Trunc]]]: ...
def compile(self, node: Any, select_format: object = ...) -> Any: ...
def deferred_to_columns(self) -> Any: ...
def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ...
def execute_sql(
self,
result_type: str = ...,
@@ -65,7 +67,7 @@ class SQLCompiler:
opts: Options,
alias: Optional[str] = ...,
default_order: str = ...,
already_seen: Optional[Union[Set[Tuple[None, Tuple[Tuple[str, str]]]], Set[Tuple[None, Tuple[Tuple[str, str]], Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]], Set[Union[Tuple[None, Tuple[Tuple[str, str]]], Tuple[Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]]]]] = ...
already_seen: Optional[Union[Set[Tuple[None, Tuple[Tuple[str, str]]]], Set[Union[Tuple[None, Tuple[Tuple[str, str]]], Tuple[Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]]], Set[Tuple[None, Tuple[Tuple[str, str]], Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]]]] = ...
) -> List[Tuple[OrderBy, bool]]: ...
def get_combinator_sql(
self,
@@ -77,22 +79,22 @@ class SQLCompiler:
self,
start_alias: Optional[str] = ...,
opts: Optional[Options] = ...,
from_parent: Any = ...
from_parent: Optional[Type[Model]] = ...
) -> List[Col]: ...
def get_distinct(self) -> Tuple[List[Any], List[Any]]: ...
def get_extra_select(
self,
order_by: Union[List[Tuple[OrderBy, Tuple[str, List[Any], bool]]], List[Union[Tuple[OrderBy, Tuple[str, List[int], bool]], Tuple[OrderBy, Tuple[str, List[Any], bool]]]], List[Tuple[OrderBy, Tuple[str, Tuple, bool]]]],
order_by: Union[List[Tuple[OrderBy, Tuple[str, List[Any], bool]]], List[Tuple[OrderBy, Tuple[str, Tuple, bool]]], List[Union[Tuple[OrderBy, Tuple[str, List[int], bool]], Tuple[OrderBy, Tuple[str, List[Any], bool]]]]],
select: Any
) -> List[Tuple[OrderBy, Tuple[str, List[Any]], None]]: ...
def get_from_clause(
self
) -> Union[Tuple[List[str], List[Union[int, str]]], Tuple[List[str], List[Any]], Tuple[List[str], List[int]], Tuple[List[str], List[str]]]: ...
) -> Union[Tuple[List[str], List[Any]], Tuple[List[str], List[Union[int, str]]], Tuple[List[str], List[int]], Tuple[List[str], List[str]]]: ...
def get_group_by(
self,
select: Any,
order_by: Any
) -> Union[List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]], List[Tuple[str, List[Any]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[int]]]]]: ...
) -> Union[List[Tuple[str, List[Any]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[int]]]]]: ...
def get_order_by(self) -> Any: ...
def get_related_selections(
self,
@@ -102,7 +104,7 @@ class SQLCompiler:
cur_depth: int = ...,
requested: Any = ...,
restricted: Optional[bool] = ...
) -> Any: ...
) -> List[Dict[str, Any]]: ...
def get_select(self) -> Any: ...
def has_results(self) -> bool: ...
def pre_sql_setup(self) -> Any: ...

View File

@@ -31,7 +31,7 @@ class BaseTable:
class Join:
def __eq__(
self,
other: Union[Join, BaseTable]
other: Union[BaseTable, Join]
) -> bool: ...
def __init__(
self,
@@ -47,17 +47,17 @@ class Join:
self,
compiler: SQLCompiler,
connection: DatabaseWrapper
) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ...
) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ...
def demote(self) -> Join: ...
def equals(
self,
other: Union[Join, BaseTable],
other: Union[BaseTable, Join],
with_filtered_relation: bool
) -> bool: ...
def promote(self) -> Join: ...
def relabeled_clone(
self,
change_map: Union[Dict[str, str], OrderedDict]
change_map: Union[OrderedDict, Dict[str, str]]
) -> Join: ...

View File

@@ -1,6 +1,6 @@
from django.db.models.base import Model
from django.db.models.sql.where import WhereNode
from typing import (
Any,
Set,
Tuple,
Type,
@@ -10,9 +10,13 @@ from typing import (
class JoinPromoter:
def __init__(self, connector: str, num_children: int, negated: bool) -> None: ...
def add_votes(self, votes: Union[Tuple, Set[str]]) -> None: ...
def add_votes(self, votes: Union[Set[str], Tuple]) -> None: ...
def update_join_types(self, query: Query) -> Set[str]: ...
class Query:
def __init__(self, model: Any, where: Type[WhereNode] = ...) -> None: ...
def __init__(
self,
model: Type[Model],
where: Type[WhereNode] = ...
) -> None: ...

View File

@@ -41,4 +41,4 @@ class UpdateQuery:
def add_update_values(self, values: Dict[str, Any]) -> None: ...
def clone(self) -> UpdateQuery: ...
def get_related_updates(self) -> List[UpdateQuery]: ...
def update_batch(self, pk_list: List[int], values: Dict[str, Union[None, int]], using: str) -> None: ...
def update_batch(self, pk_list: List[int], values: Dict[str, Optional[int]], using: str) -> None: ...

View File

@@ -79,7 +79,7 @@ class WhereNode:
) -> Union[List[CombinedExpression], List[Col]]: ...
def get_source_expressions(
self
) -> Union[List[GreaterThan], List[IntegerLessThan], List[Exact], List[LessThanOrEqual]]: ...
) -> Union[List[GreaterThan], List[LessThanOrEqual], List[Exact], List[IntegerLessThan]]: ...
def relabel_aliases(
self,
change_map: Union[OrderedDict, Dict[str, str], Dict[Union[str, None], str]]
@@ -96,4 +96,4 @@ class WhereNode:
def split_having(
self,
negated: bool = ...
) -> Union[Tuple[WhereNode, None], Tuple[None, WhereNode], Tuple[WhereNode, WhereNode]]: ...
) -> Union[Tuple[None, WhereNode], Tuple[WhereNode, WhereNode], Tuple[WhereNode, None]]: ...

View File

@@ -1,4 +1,7 @@
from django.apps.config import AppConfig
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.models import Session
from django.contrib.sites.models import Site
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
@@ -7,6 +10,8 @@ from typing import (
Callable,
Dict,
List,
Type,
Union,
)
@@ -27,16 +32,16 @@ class ConnectionHandler:
class ConnectionRouter:
def __init__(self, routers: None = ...) -> None: ...
def allow_migrate(self, db: str, app_label: str, **hints) -> bool: ...
def allow_migrate_model(self, db: str, model: Any) -> bool: ...
def allow_migrate_model(self, db: str, model: Type[Model]) -> bool: ...
def allow_relation(self, obj1: Model, obj2: Model, **hints) -> bool: ...
def get_migratable_models(
self,
app_config: AppConfig,
db: str,
include_auto_created: bool = ...
) -> Any: ...
) -> Union[List[Type[Model]], List[Type[Site]], List[Type[Session]], List[Type[ContentType]]]: ...
@cached_property
def routers(self) -> Any: ...
def routers(self) -> List[object]: ...
class DatabaseErrorWrapper: