third iteration of stubs

This commit is contained in:
Maxim Kurnikov
2018-08-11 00:19:50 +03:00
parent fa718b8e55
commit c6bceb19f4
216 changed files with 16306 additions and 3006 deletions

View File

@@ -1,22 +1,29 @@
from collections import OrderedDict, namedtuple
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
from datetime import date, datetime, time, timedelta
from decimal import Decimal
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union)
from uuid import UUID
from django.contrib.contenttypes.models import ContentType
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.aggregates import Aggregate
from django.db.models.base import Model
from django.db.models.expressions import Col, Combinable
from django.db.models.fields import Field
from django.db.models.fields.files import ImageField
from django.db.models.base import Model, ModelState
from django.db.models.expressions import (Combinable, CombinedExpression,
Expression, F, SQLiteNumericMixin)
from django.db.models.fields import Field, TextField
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related_lookups import MultiColSource
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.lookups import BuiltinLookup
from django.db.models.fields.reverse_related import (ForeignObjectRel,
ManyToOneRel)
from django.db.models.functions.datetime import TimezoneMixin
from django.db.models.lookups import (FieldGetDbPrepValueMixin, Lookup,
Transform)
from django.db.models.options import Options
from django.db.models.query_utils import PathInfo, Q
from django.db.models.query import QuerySet
from django.db.models.query_utils import FilteredRelation, PathInfo, Q
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.datastructures import BaseTable, Join
from django.db.models.sql.subqueries import UpdateQuery
from django.db.models.sql.where import WhereNode
JoinInfo = namedtuple(
@@ -25,35 +32,77 @@ JoinInfo = namedtuple(
)
class RawQuery:
params: Any = ...
sql: Any = ...
using: Any = ...
cursor: Any = ...
extra_select: Any = ...
annotation_select: Any = ...
high_mark: None
low_mark: int
params: Union[
Dict[str, str],
List[datetime.datetime],
List[decimal.Decimal],
List[str],
Set[str],
Tuple,
] = ...
sql: str = ...
using: str = ...
cursor: Optional[django.db.backends.utils.CursorWrapper] = ...
extra_select: Dict[Any, Any] = ...
annotation_select: Dict[Any, Any] = ...
def __init__(
self, sql: Any, using: Any, params: Optional[Any] = ...
self,
sql: str,
using: str,
params: Optional[
Union[
Dict[str, str],
List[datetime],
List[Decimal],
List[str],
Set[str],
Tuple[int],
]
] = ...,
) -> None: ...
def chain(self, using: Any): ...
def clone(self, using: Any): ...
def get_columns(self): ...
def chain(self, using: str) -> RawQuery: ...
def clone(self, using: str) -> RawQuery: ...
def get_columns(self) -> List[str]: ...
def __iter__(self): ...
@property
def params_type(self): ...
def params_type(self) -> Type[Union[dict, tuple]]: ...
class Query:
base_table: str
related_ids: None
related_updates: Dict[Any, Any]
related_updates: Union[
Dict[
Type[django.db.models.base.Model],
List[Tuple[django.db.models.fields.CharField, None, str]],
],
Dict[
Type[django.db.models.base.Model],
List[Tuple[django.db.models.fields.IntegerField, None, int]],
],
]
values: Union[
List[
Tuple[
django.db.models.fields.CharField,
Type[django.db.models.base.Model],
str,
django.db.models.aggregates.Max,
]
],
List[
Tuple[
django.db.models.fields.IntegerField,
Type[django.db.models.base.Model],
int,
]
],
List[
Union[
Tuple[django.db.models.fields.BooleanField, bool, bool],
Tuple[django.db.models.fields.CharField, str, str],
]
],
List[Tuple[django.db.models.fields.Field, None, Union[str, bool]]],
]
alias_prefix: str = ...
subq_aliases: frozenset = ...
@@ -61,7 +110,7 @@ class Query:
model: Optional[Type[django.db.models.base.Model]] = ...
alias_refcount: Dict[str, int] = ...
alias_map: collections.OrderedDict = ...
external_aliases: Set[Any] = ...
external_aliases: Set[str] = ...
table_map: Dict[str, List[str]] = ...
default_cols: bool = ...
default_ordering: bool = ...
@@ -69,10 +118,10 @@ class Query:
used_aliases: Set[str] = ...
filter_is_sticky: bool = ...
subquery: bool = ...
select: Union[Tuple, List[Any]] = ...
select: Union[List[django.db.models.expressions.Col], Tuple] = ...
where: django.db.models.sql.where.WhereNode = ...
where_class: Type[django.db.models.sql.where.WhereNode] = ...
group_by: Optional[bool] = ...
group_by: Optional[Union[Tuple, bool]] = ...
order_by: Tuple = ...
distinct: bool = ...
distinct_fields: Tuple = ...
@@ -80,63 +129,108 @@ class Query:
select_for_update_nowait: bool = ...
select_for_update_skip_locked: bool = ...
select_for_update_of: Tuple = ...
select_related: Union[bool, Dict[str, Dict[Any, Any]]] = ...
select_related: Union[
Dict[
str,
Dict[
str,
Dict[
str,
Dict[str, Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]]],
],
],
],
bool,
] = ...
max_depth: int = ...
values_select: Tuple = ...
annotation_select_mask: Optional[Set[str]] = ...
combinator: None = ...
combinator: Optional[str] = ...
combinator_all: bool = ...
combined_queries: Tuple = ...
extra_select_mask: Optional[Set[str]] = ...
extra_tables: Tuple = ...
extra_order_by: Tuple = ...
deferred_loading: Tuple[frozenset, bool] = ...
extra_order_by: Union[List[str], Tuple] = ...
deferred_loading: Tuple[bool, bool] = ...
explain_query: bool = ...
explain_format: None = ...
explain_options: Dict[Any, Any] = ...
explain_format: Optional[str] = ...
explain_options: Dict[str, int] = ...
def __init__(
self, model: Type[Model], where: Type[WhereNode] = ...
self, model: Optional[Type[Model]], where: Type[WhereNode] = ...
) -> None: ...
@property
def extra(self) -> OrderedDict: ...
@property
def annotations(self) -> OrderedDict: ...
@property
def has_select_fields(self): ...
def has_select_fields(self) -> bool: ...
def base_table(self) -> str: ...
def sql_with_params(self) -> Tuple[str, Tuple[int, int, int, int]]: ...
def __deepcopy__(self, memo: Any): ...
def sql_with_params(self) -> Tuple[str, Tuple]: ...
def __deepcopy__(
self,
memo: Dict[
int,
Union[
Dict[str, Union[ModelState, int, str]],
List[
Union[
Dict[Any, Any], Dict[str, Union[bool, str]], ModelState
]
],
Model,
ModelState,
],
],
) -> Query: ...
def get_compiler(
self, using: str = ..., connection: None = ...
self,
using: Optional[str] = ...,
connection: Optional[DatabaseWrapper] = ...,
) -> SQLCompiler: ...
def get_meta(self) -> Options: ...
def clone(self) -> Query: ...
def chain(self, klass: Optional[Type[UpdateQuery]] = ...) -> Query: ...
def relabeled_clone(self, change_map: Any): ...
def rewrite_cols(self, annotation: Any, col_cnt: Any): ...
def chain(self, klass: Optional[Type[Query]] = ...) -> Query: ...
def relabeled_clone(self, change_map: Dict[Any, Any]) -> Query: ...
def rewrite_cols(
self,
annotation: Union[Expression, FieldGetDbPrepValueMixin, WhereNode],
col_cnt: int,
) -> Tuple[int, int]: ...
def get_aggregation(
self, using: str, added_aggregate_names: Dict[str, Aggregate]
) -> Dict[str, datetime]: ...
def get_count(self, using: Any): ...
def has_filters(self): ...
self,
using: str,
added_aggregate_names: Union[
Dict[str, Union[Aggregate, CombinedExpression]], List[str]
],
) -> Union[
Dict[str, Optional[int]],
Dict[str, Union[date, time]],
Dict[str, Union[Decimal, float, int]],
Dict[str, timedelta],
]: ...
def get_count(self, using: str) -> int: ...
def has_filters(self) -> WhereNode: ...
def has_results(self, using: str) -> bool: ...
def explain(
self, using: Any, format: Optional[Any] = ..., **options: Any
): ...
def combine(self, rhs: Any, connector: Any) -> None: ...
self, using: str, format: Optional[str] = ..., **options: Any
) -> str: ...
def combine(self, rhs: Query, connector: str) -> None: ...
def deferred_to_data(
self, target: Dict[Any, Any], callback: Callable
) -> None: ...
def table_alias(
self, table_name: str, create: bool = ..., filtered_relation: None = ...
self,
table_name: str,
create: bool = ...,
filtered_relation: Optional[FilteredRelation] = ...,
) -> Tuple[str, bool]: ...
def ref_alias(self, alias: str) -> None: ...
def unref_alias(self, alias: str, amount: int = ...) -> None: ...
def promote_joins(self, aliases: Set[Any]) -> None: ...
def promote_joins(self, aliases: Set[str]) -> None: ...
def demote_joins(self, aliases: Set[str]) -> None: ...
def reset_refcounts(self, to_counts: Dict[str, int]) -> None: ...
def change_aliases(self, change_map: Any) -> None: ...
def bump_prefix(self, outer_query: Any): ...
def change_aliases(self, change_map: Dict[Any, Any]) -> None: ...
def bump_prefix(self, outer_query: Query) -> None: ...
def get_initial_alias(self) -> str: ...
def count_active_tables(self) -> int: ...
def join(
@@ -155,55 +249,236 @@ class Query:
def add_annotation(
self, annotation: Combinable, alias: str, is_summary: bool = ...
) -> None: ...
def resolve_expression(self, query: Any, *args: Any, **kwargs: Any): ...
def resolve_expression(
self, query: Query, *args: Any, **kwargs: Any
) -> Query: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Union[Tuple[str, str], Tuple[str, int]]]: ...
) -> Tuple[str, Tuple]: ...
def resolve_lookup_value(
self, value: Any, can_reuse: Set[str], allow_joins: bool
) -> Any: ...
self,
value: Optional[
Union[
Dict[Any, Any],
Iterator[Any],
List[Dict[str, str]],
List[None],
List[Union[List[str], Combinable]],
List[Union[Model, int]],
List[Union[int, str]],
List[datetime],
Set[Optional[int]],
Set[ContentType],
Set[str],
Set[UUID],
Tuple,
bytes,
date,
timedelta,
Decimal,
Model,
Combinable,
QuerySet,
Query,
float,
frozenset,
int,
range,
str,
UUID,
]
],
can_reuse: Optional[Set[str]],
allow_joins: bool,
) -> Optional[
Union[
Dict[Any, Any],
Iterator[Any],
List[Dict[str, str]],
List[None],
List[Union[List[str], Combinable]],
List[Union[Model, int]],
List[Union[int, str]],
List[datetime],
Set[Optional[int]],
Set[ContentType],
Set[str],
Set[UUID],
Tuple,
bytes,
date,
timedelta,
Decimal,
Model,
Combinable,
Query,
float,
frozenset,
int,
range,
str,
UUID,
]
]: ...
def solve_lookup_type(
self, lookup: str
) -> Union[
Tuple[List[str], List[str], bool], Tuple[List[str], Tuple, Col]
Tuple[List[str], List[str], bool],
Tuple[List[str], Tuple, Union[Expression, SQLiteNumericMixin]],
]: ...
def check_query_object_type(
self, value: Union[Model, int], opts: Options, field: FieldCacheMixin
self,
value: Union[Model, int, str, UUID],
opts: Options,
field: FieldCacheMixin,
) -> None: ...
def check_related_objects(
self,
field: Union[Field, reverse_related.ForeignObjectRel],
value: Any,
field: Union[Field, ForeignObjectRel],
value: Optional[
Union[
Dict[Any, Any],
List[Dict[str, str]],
List[None],
List[Union[List[str], Combinable]],
List[Union[Model, int]],
List[Union[int, str]],
List[datetime],
Set[Optional[int]],
Set[ContentType],
Set[str],
Set[UUID],
Tuple,
bytes,
date,
timedelta,
Decimal,
Model,
Combinable,
Query,
float,
frozenset,
int,
range,
str,
UUID,
]
],
opts: Options,
) -> None: ...
def build_lookup(
self, lookups: List[str], lhs: Union[Col, MultiColSource], rhs: Any
) -> BuiltinLookup: ...
def try_transform(self, lhs: Col, name: str) -> Any: ...
self,
lookups: List[str],
lhs: Union[Expression, TextField, related_lookups.MultiColSource],
rhs: Optional[
Union[
Dict[Any, Any],
List[Dict[str, str]],
List[None],
List[Union[List[str], Combinable]],
List[Union[Model, int]],
List[Union[int, str]],
List[datetime],
Set[Optional[int]],
Set[ContentType],
Set[str],
Set[UUID],
Tuple,
bytes,
date,
timedelta,
Decimal,
Model,
Combinable,
Query,
float,
frozenset,
int,
range,
str,
UUID,
]
],
) -> Lookup: ...
def try_transform(self, lhs: Expression, name: str) -> Transform: ...
def build_filter(
self,
filter_expr: Tuple[str, Any],
filter_expr: Union[
Dict[str, str],
Tuple[
str,
Optional[
Union[
Dict[Any, Any],
Iterator[Any],
List[Dict[str, str]],
List[List[str]],
List[None],
List[Union[Model, int]],
List[Union[int, str]],
List[datetime],
List[Combinable],
Set[Optional[int]],
Set[ContentType],
Set[str],
Set[UUID],
Tuple,
bytes,
date,
timedelta,
Decimal,
Model,
Combinable,
django.db.models.functions.TimezoneMixin,
QuerySet,
Query,
float,
frozenset,
int,
range,
str,
UUID,
]
],
],
],
branch_negated: bool = ...,
current_negated: bool = ...,
can_reuse: Set[str] = ...,
can_reuse: Optional[Set[str]] = ...,
allow_joins: bool = ...,
split_subq: bool = ...,
reuse_with_filtered_relation: bool = ...,
) -> Tuple[WhereNode, Union[Tuple, Set[str], List[Any]]]: ...
) -> Tuple[WhereNode, Union[List[Any], Set[str], Tuple]]: ...
def add_filter(
self,
filter_clause: Tuple[str, Optional[Union[Tuple[str, str], str, Model]]],
filter_clause: Tuple[
str,
Optional[
Union[
List[Model],
List[int],
List[str],
Tuple[str, str],
Model,
F,
QuerySet,
Query,
int,
str,
]
],
],
) -> None: ...
def add_q(self, q_object: Q) -> None: ...
def build_filtered_relation_q(
self,
q_object: Any,
reuse: Any,
q_object: Q,
reuse: Set[str],
branch_negated: bool = ...,
current_negated: bool = ...,
): ...
) -> WhereNode: ...
def add_filtered_relation(
self, filtered_relation: Any, alias: Any
self, filtered_relation: FilteredRelation, alias: str
) -> None: ...
def names_to_path(
self,
@@ -212,20 +487,8 @@ class Query:
allow_many: bool = ...,
fail_on_missing: bool = ...,
) -> Union[
Tuple[
List[PathInfo],
Field,
Tuple[Field],
Union[List[str], List[Any]],
Union[List[str], List[Any]],
],
Tuple[
List[PathInfo],
Tuple[Field],
List[str],
Union[List[str], List[Any]],
Union[List[str], List[Any]],
],
Tuple[List[PathInfo], Tuple[Field], List[str], List[str]],
Tuple[List[PathInfo], ForeignObjectRel, Tuple[Field], List[str]],
]: ...
def setup_joins(
self,
@@ -243,69 +506,98 @@ class Query:
self,
name: str,
allow_joins: bool = ...,
reuse: None = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
) -> Col: ...
) -> Expression: ...
def split_exclude(
self,
filter_expr: Tuple[str, Optional[Union[Tuple[str, str], str, Model]]],
filter_expr: Tuple[
str,
Optional[
Union[
List[Model],
List[str],
Tuple[str, str],
Model,
F,
QuerySet,
int,
str,
]
],
],
can_reuse: Set[str],
names_with_path: List[Tuple[str, List[PathInfo]]],
) -> Tuple[WhereNode, Tuple]: ...
def set_empty(self) -> None: ...
def is_empty(self): ...
def is_empty(self) -> bool: ...
high_mark: Optional[int] = ...
low_mark: int = ...
def set_limits(self, low: None = ..., high: int = ...) -> None: ...
def set_limits(
self, low: Optional[int] = ..., high: Optional[int] = ...
) -> None: ...
def clear_limits(self) -> None: ...
def has_limit_one(self): ...
def has_limit_one(self) -> bool: ...
def can_filter(self) -> bool: ...
def clear_select_clause(self) -> None: ...
def clear_select_fields(self) -> None: ...
def set_select(self, cols: List[Col]) -> None: ...
def set_select(self, cols: List[Expression]) -> None: ...
def add_distinct_fields(self, *field_names: Any) -> None: ...
def add_fields(
self, field_names: List[str], allow_m2m: bool = ...
self,
field_names: Union[Iterator[Any], List[str]],
allow_m2m: bool = ...,
) -> None: ...
def add_ordering(self, *ordering: Any) -> None: ...
def clear_ordering(self, force_empty: bool) -> None: ...
def set_group_by(self) -> None: ...
def add_select_related(self, fields: Tuple[str, str]) -> None: ...
def add_select_related(self, fields: Tuple[str]) -> None: ...
def add_extra(
self,
select: Optional[Union[OrderedDict, Dict[str, str], Dict[str, int]]],
select_params: Optional[Union[List[int], Tuple[int, int]]],
where: None,
params: None,
tables: None,
order_by: Optional[List[str]],
select: Optional[Union[Dict[str, int], Dict[str, str]]],
select_params: Optional[Union[List[int], List[str], Tuple[int]]],
where: Optional[List[str]],
params: Optional[List[str]],
tables: Optional[List[str]],
order_by: Optional[Union[List[str], Tuple[str]]],
) -> None: ...
def clear_deferred_loading(self) -> None: ...
def add_deferred_loading(self, field_names: Any) -> None: ...
def add_immediate_loading(self, field_names: Any) -> None: ...
def get_loaded_field_names(self): ...
def add_deferred_loading(self, field_names: Tuple[str]) -> None: ...
def add_immediate_loading(self, field_names: Tuple[str]) -> None: ...
def get_loaded_field_names(
self
) -> Dict[Type[Model], Union[Set[Any], Set[str]]]: ...
def get_loaded_field_names_cb(
self, target: Dict[Any, Any], model: Type[Model], fields: Field
self,
target: Dict[Type[Model], Union[Set[Any], Set[str]]],
model: Type[Model],
fields: Union[Set[Field], Set[ManyToOneRel]],
) -> None: ...
def set_annotation_mask(self, names: Union[Tuple, List[str]]) -> None: ...
def append_annotation_mask(self, names: Any) -> None: ...
def set_extra_mask(self, names: Union[Tuple, List[str]]) -> None: ...
def set_values(self, fields: Union[List[str], Tuple[str]]) -> None: ...
def set_annotation_mask(
self, names: Optional[Union[List[str], Set[str], Tuple]]
) -> None: ...
def append_annotation_mask(self, names: List[str]) -> None: ...
def set_extra_mask(self, names: Union[List[str], Tuple]) -> None: ...
def set_values(self, fields: Union[List[str], Tuple]) -> None: ...
@property
def annotation_select(self) -> Dict[Any, Any]: ...
@property
def extra_select(self) -> Union[OrderedDict, Dict[Any, Any]]: ...
def trim_start(self, names_with_path: Any): ...
def extra_select(self) -> Dict[Any, Any]: ...
def trim_start(
self, names_with_path: List[Tuple[str, List[PathInfo]]]
) -> Tuple[str, bool]: ...
def is_nullable(self, field: Field) -> bool: ...
class JoinPromoter:
connector: Any = ...
negated: Any = ...
effective_connector: Any = ...
num_children: Any = ...
votes: Any = ...
connector: str = ...
negated: bool = ...
effective_connector: str = ...
num_children: int = ...
votes: collections.Counter = ...
def __init__(
self, connector: str, num_children: int, negated: bool
) -> None: ...
def add_votes(self, votes: Union[Tuple, Set[str], List[Any]]) -> None: ...
def add_votes(
self, votes: Union[Iterator[Any], List[Any], Set[str], Tuple]
) -> None: ...
def update_join_types(self, query: Query) -> Set[str]: ...