move generated stubs to separate directory, too messty

This commit is contained in:
Maxim Kurnikov
2018-11-10 17:49:18 +03:00
parent 7436d641e3
commit 96cd3ddb27
446 changed files with 58 additions and 71 deletions

View File

@@ -0,0 +1,96 @@
# noinspection PyUnresolvedReferences
from django.core.exceptions import (
ObjectDoesNotExist as ObjectDoesNotExist
)
# noinspection PyUnresolvedReferences
from django.db.models import (
signals as signals
)
# noinspection PyUnresolvedReferences
from django.db.models.aggregates import * # NOQA
# noinspection PyUnresolvedReferences
from django.db.models.aggregates import __all__ as aggregates_all
# noinspection PyUnresolvedReferences
from django.db.models.deletion import (
CASCADE as CASCADE,
DO_NOTHING as DO_NOTHING,
PROTECT as PROTECT,
SET as SET,
SET_DEFAULT as SET_DEFAULT,
SET_NULL as SET_NULL,
ProtectedError as ProtectedError,
)
# noinspection PyUnresolvedReferences
from django.db.models.expressions import (
Case as Case,
Exists as Exists,
Expression as Expression,
ExpressionList as ExpressionList,
ExpressionWrapper as ExpressionWrapper,
F as F,
Func as Func,
OuterRef as OuterRef,
RowRange as RowRange,
Subquery as Subquery,
Value as Value,
ValueRange as ValueRange,
When as When,
Window as Window,
WindowFrame as WindowFrame,
)
# noinspection PyUnresolvedReferences
from django.db.models.fields import * # NOQA
# noinspection PyUnresolvedReferences
from django.db.models.fields.files import (
FileField as FileField,
ImageField as ImageField
)
# noinspection PyUnresolvedReferences
from django.db.models.fields.proxy import OrderWrt
# noinspection PyUnresolvedReferences
from django.db.models.indexes import * # NOQA
# noinspection PyUnresolvedReferences
from django.db.models.lookups import (
Lookup as Lookup,
Transform as Transform
)
# noinspection PyUnresolvedReferences
from django.db.models.manager import Manager as Manager
# noinspection PyUnresolvedReferences
from django.db.models.query import (
Prefetch as Prefetch,
Q as Q,
QuerySet as QuerySet,
prefetch_related_objects as prefetch_related_objects,
)
# noinspection PyUnresolvedReferences
from django.db.models.query_utils import FilteredRelation as FilteredRelation
# Imports that would create circular imports if sorted
# noinspection PyUnresolvedReferences
from django.db.models.base import DEFERRED as DEFERRED, Model as Model # isort:skip
# noinspection PyUnresolvedReferences
from django.db.models.fields.related import ( # isort:skip
ForeignKey as ForeignKey,
ForeignObject as ForeignObject,
OneToOneField as OneToOneField,
ManyToManyField as ManyToManyField,
ManyToOneRel as ManyToOneRel,
ManyToManyRel as ManyToManyRel,
OneToOneRel as OneToOneRel
)

View File

@@ -0,0 +1,105 @@
from decimal import Decimal
from typing import Any, List, Optional, Tuple, Union
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.expressions import Combinable, Expression, Func
from django.db.models.fields import Field
from django.db.models.query_utils import Q
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
from django.db.models.sql.where import WhereNode
class Aggregate(Func):
contains_aggregate: bool = ...
name: Any = ...
filter_template: str = ...
window_compatible: bool = ...
filter: Any = ...
def __init__(
self, *args: Any, filter: Optional[Any] = ..., **kwargs: Any
) -> None: ...
def get_source_fields(self) -> Union[List[None], List[Field]]: ...
def get_source_expressions(self) -> List[Union[Combinable, WhereNode]]: ...
def set_source_expressions(
self, exprs: List[Union[Expression, WhereNode]]
) -> None: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: None = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Aggregate: ...
@property
def default_alias(self) -> str: ...
def get_group_by_cols(self) -> List[Any]: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context: Any
) -> Tuple[str, Union[List[Decimal], List[int]]]: ...
class Avg(Aggregate):
filter: None
function: str = ...
name: str = ...
def as_mysql(self, compiler: Any, connection: Any): ...
def as_oracle(self, compiler: Any, connection: Any): ...
class Count(Aggregate):
filter: None
function: str = ...
name: str = ...
template: str = ...
output_field: Any = ...
def __init__(
self,
expression: str,
distinct: bool = ...,
filter: Optional[Q] = ...,
**extra: Any
) -> None: ...
def convert_value(
self,
value: Optional[int],
expression: Count,
connection: DatabaseWrapper,
) -> int: ...
class Max(Aggregate):
filter: None
function: str = ...
name: str = ...
class Min(Aggregate):
filter: None
function: str = ...
name: str = ...
class StdDev(Aggregate):
filter: None
name: str = ...
output_field: Any = ...
function: str = ...
def __init__(
self, expression: str, sample: bool = ..., **extra: Any
) -> None: ...
class Sum(Aggregate):
filter: None
function: str = ...
name: str = ...
def as_mysql(self, compiler: Any, connection: Any): ...
def as_oracle(self, compiler: Any, connection: Any): ...
class Variance(Aggregate):
filter: None
name: str = ...
output_field: Any = ...
function: str = ...
def __init__(
self, expression: str, sample: bool = ..., **extra: Any
) -> None: ...

View File

@@ -0,0 +1,110 @@
from datetime import date
from decimal import Decimal
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from uuid import UUID
from django.core.checks.messages import Warning
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from django.db.models.fields.related import ForeignKey
class Deferred: ...
DEFERRED: Any
def subclass_exception(
name: str,
bases: Tuple[Type[Exception]],
module: str,
attached_to: Type[Model],
) -> Type[Exception]: ...
class ModelBase(type):
def __new__(
cls: Type[ModelBase],
name: str,
bases: Tuple[Type[Model]],
attrs: Dict[str, Any],
**kwargs: Any
) -> Type[Model]: ...
def add_to_class(cls, name: str, value: Any) -> None: ...
class ModelStateFieldsCacheDescriptor:
def __get__(
self, instance: ModelState, cls: Type[ModelState] = ...
) -> Dict[Any, Any]: ...
class ModelState:
db: Any = ...
adding: bool = ...
fields_cache: Any = ...
class Model:
class DoesNotExist(ObjectDoesNotExist):
pass
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@classmethod
def from_db(
cls,
db: str,
field_names: List[str],
values: Union[
List[Optional[Union[date, int, str]]],
List[Optional[UUID]],
List[Union[Decimal, int]],
List[Union[int, UUID]],
Tuple[Union[int, str]],
],
) -> Model: ...
def __eq__(self, other: Any) -> bool: ...
def __hash__(self) -> int: ...
def __reduce__(self): ...
pk: Any = ...
def get_deferred_fields(self) -> Set[str]: ...
def refresh_from_db(
self, using: None = ..., fields: Optional[List[str]] = ...
) -> None: ...
def serializable_value(self, field_name: str) -> Union[int, str]: ...
def save(
self,
force_insert: bool = ...,
force_update: bool = ...,
using: Optional[str] = ...,
update_fields: Optional[List[str]] = ...,
) -> None: ...
def save_base(
self,
raw: bool = ...,
force_insert: bool = ...,
force_update: bool = ...,
using: str = ...,
update_fields: Optional[frozenset] = ...,
) -> None: ...
def delete(
self, using: None = ..., keep_parents: bool = ...
) -> Tuple[int, Dict[str, int]]: ...
def prepare_database_save(self, field: ForeignKey) -> UUID: ...
def clean(self) -> None: ...
def validate_unique(self, exclude: List[str] = ...) -> None: ...
def date_error_message(
self, lookup_type: Any, field_name: Any, unique_for: Any
): ...
def unique_error_message(
self, model_class: Type[Model], unique_check: Tuple[str, str]
) -> ValidationError: ...
def full_clean(
self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...
) -> None: ...
def clean_fields(self, exclude: List[str] = ...) -> None: ...
@classmethod
def check(cls, **kwargs: Any) -> List[Warning]: ...
def method_set_order(
self, ordered_obj: Any, id_list: Any, using: Optional[Any] = ...
) -> None: ...
def method_get_order(self, ordered_obj: Any): ...
def make_foreign_order_accessors(
model: Type[Model], related_model: Type[Model]
) -> None: ...
def model_unpickle(model_id: Any): ...

View File

@@ -0,0 +1,76 @@
from typing import (Any, Callable, Dict, Iterator, List, Optional, Tuple, Type,
Union)
from django.db import IntegrityError
from django.db.models.base import Model
from django.db.models.fields.related import ForeignKey
from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.options import Options
from django.db.models.query import QuerySet
class ProtectedError(IntegrityError):
protected_objects: django.db.models.query.QuerySet = ...
def __init__(
self, msg: str, protected_objects: Union[List[Model], QuerySet]
) -> None: ...
def CASCADE(
collector: Collector, field: ForeignKey, sub_objs: QuerySet, using: str
) -> None: ...
def PROTECT(
collector: Collector, field: ForeignKey, sub_objs: QuerySet, using: str
) -> Any: ...
def SET(value: Callable) -> Callable: ...
def SET_NULL(
collector: Collector, field: ForeignKey, sub_objs: QuerySet, using: str
) -> None: ...
def SET_DEFAULT(
collector: Collector, field: ForeignKey, sub_objs: QuerySet, using: str
) -> None: ...
def DO_NOTHING(
collector: Any, field: Any, sub_objs: Any, using: Any
) -> None: ...
def get_candidate_relations_to_delete(opts: Options) -> Iterator[Any]: ...
class Collector:
using: str = ...
data: collections.OrderedDict = ...
field_updates: Dict[Any, Any] = ...
fast_deletes: List[Any] = ...
dependencies: Dict[Any, Any] = ...
def __init__(self, using: str) -> None: ...
def add(
self,
objs: Union[List[Model], QuerySet],
source: Optional[Type[Model]] = ...,
nullable: bool = ...,
reverse_dependency: bool = ...,
) -> List[Model]: ...
def add_field_update(
self, field: ForeignKey, value: Optional[int], objs: QuerySet
) -> None: ...
def can_fast_delete(
self,
objs: Union[List[Model], QuerySet],
from_field: Optional[ForeignKey] = ...,
) -> bool: ...
def get_del_batches(
self, objs: List[Model], field: ForeignKey
) -> List[List[Model]]: ...
def collect(
self,
objs: Union[List[Model], QuerySet],
source: Optional[Type[Model]] = ...,
nullable: bool = ...,
collect_related: bool = ...,
source_attr: Optional[str] = ...,
reverse_dependency: bool = ...,
keep_parents: bool = ...,
) -> None: ...
def related_objects(
self, related: ManyToOneRel, objs: List[Model]
) -> QuerySet: ...
def instances_with_model(self) -> Iterator[Tuple[Type[Model], Model]]: ...
def sort(self) -> None: ...
def delete(self) -> Tuple[int, Dict[str, int]]: ...

View File

@@ -0,0 +1,536 @@
from collections import OrderedDict
from datetime import datetime, timedelta
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union)
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.aggregates import Aggregate, Count
from django.db.models.fields import Field, DurationField
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.functions.window import DenseRank
from django.db.models.lookups import (FieldGetDbPrepValueMixin, Lookup,
Transform)
from django.db.models.query import QuerySet
from django.db.models.query_utils import Q
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
from django.db.models.sql.where import WhereNode
from django.utils.tree import Node
class SQLiteNumericMixin:
def as_sqlite(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context: Any
) -> Tuple[str, List[float]]: ...
class Combinable:
ADD: str = ...
SUB: str = ...
MUL: str = ...
DIV: str = ...
POW: str = ...
MOD: str = ...
BITAND: str = ...
BITOR: str = ...
BITLEFTSHIFT: str = ...
BITRIGHTSHIFT: str = ...
def __neg__(self) -> CombinedExpression: ...
def __add__(
self, other: Optional[Union[timedelta, Combinable, float, str]]
) -> CombinedExpression: ...
def __sub__(
self, other: Union[timedelta, Combinable, float]
) -> CombinedExpression: ...
def __mul__(
self, other: Union[timedelta, Combinable, float]
) -> CombinedExpression: ...
def __truediv__(self, other: Union[Count, float]) -> CombinedExpression: ...
def __mod__(self, other: int) -> CombinedExpression: ...
def __pow__(self, other: float) -> CombinedExpression: ...
def __and__(self, other: Combinable) -> Any: ...
def bitand(self, other: int) -> CombinedExpression: ...
def bitleftshift(self, other: int) -> CombinedExpression: ...
def bitrightshift(self, other: int) -> CombinedExpression: ...
def __or__(self, other: Combinable) -> Any: ...
def bitor(self, other: int) -> CombinedExpression: ...
def __radd__(
self, other: Optional[Union[datetime, float]]
) -> CombinedExpression: ...
def __rsub__(self, other: float) -> CombinedExpression: ...
def __rmul__(self, other: float) -> CombinedExpression: ...
def __rtruediv__(self, other: float) -> CombinedExpression: ...
def __rmod__(self, other: int) -> CombinedExpression: ...
def __rpow__(self, other: float) -> CombinedExpression: ...
def __rand__(self, other: Any) -> Any: ...
def __ror__(self, other: Any) -> Any: ...
class BaseExpression:
is_summary: bool = ...
filterable: bool = ...
window_compatible: bool = ...
output_field: Any = ...
def __init__(
self, output_field: Optional[Union[Field, ForeignObjectRel, str]] = ...
) -> None: ...
def get_db_converters(
self, connection: DatabaseWrapper
) -> List[Callable]: ...
def get_source_expressions(self) -> List[Any]: ...
def set_source_expressions(self, exprs: List[Any]) -> None: ...
def as_sql(self, compiler: Any, connection: Any) -> None: ...
def contains_aggregate(self) -> bool: ...
def contains_over_clause(self) -> bool: ...
def contains_column_references(self) -> bool: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> BaseExpression: ...
@property
def field(self) -> Field: ...
def output_field(self) -> Field: ...
def convert_value(self) -> Callable: ...
def get_lookup(
self, lookup: str
) -> Optional[Type[Union[FieldGetDbPrepValueMixin, Lookup]]]: ...
def get_transform(self, name: str) -> Optional[Type[Transform]]: ...
def relabeled_clone(
self, change_map: Union[Dict[Optional[str], str], OrderedDict]
) -> Expression: ...
def copy(self) -> BaseExpression: ...
def get_group_by_cols(self) -> List[Expression]: ...
def get_source_fields(self) -> List[Optional[Field]]: ...
def asc(self, **kwargs: Any) -> OrderBy: ...
def desc(self, **kwargs: Any) -> OrderBy: ...
def reverse_ordering(self): ...
def flatten(self) -> Iterator[Expression]: ...
def __eq__(self, other: Combinable) -> bool: ...
def __hash__(self) -> int: ...
class Expression(BaseExpression, Combinable): ...
class CombinedExpression(SQLiteNumericMixin, Expression):
connector: Any = ...
lhs: Any = ...
rhs: Any = ...
def __init__(
self,
lhs: Combinable,
connector: str,
rhs: Combinable,
output_field: None = ...,
) -> None: ...
def get_source_expressions(
self
) -> Union[List[Combinable], List[SQLiteNumericMixin]]: ...
def set_source_expressions(self, exprs: List[Combinable]) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[float]]: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> CombinedExpression: ...
class DurationExpression(CombinedExpression):
def compile(
self,
side: Expression,
compiler: SQLCompiler,
connection: DatabaseWrapper,
) -> Tuple[str, Union[List[datetime], List[int]]]: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Union[List[datetime], List[int]]]: ...
class TemporalSubtraction(CombinedExpression):
output_field: Any = ...
def __init__(self, lhs: Col, rhs: Expression) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
class F(Combinable):
filterable: bool = ...
name: str = ...
def __init__(self, name: Union[OuterRef, str]) -> None: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Expression: ...
def asc(self, **kwargs: Any) -> OrderBy: ...
def desc(self, **kwargs: Any) -> OrderBy: ...
def __eq__(self, other: Combinable) -> bool: ...
def __hash__(self) -> int: ...
class ResolvedOuterRef(F):
name: str
def as_sql(self, *args: Any, **kwargs: Any) -> Any: ...
def relabeled_clone(self, relabels: OrderedDict) -> ResolvedOuterRef: ...
class OuterRef(F):
name: str
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> F: ...
class Func(SQLiteNumericMixin, Expression):
function: Any = ...
template: str = ...
arg_joiner: str = ...
arity: Any = ...
source_expressions: Any = ...
extra: Any = ...
def __init__(
self, *expressions: Any, output_field: Optional[Any] = ..., **extra: Any
) -> None: ...
def get_source_expressions(self) -> List[Combinable]: ...
def set_source_expressions(self, exprs: List[Expression]) -> None: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[Any]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Func: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
function: Optional[str] = ...,
template: Optional[str] = ...,
arg_joiner: Optional[str] = ...,
**extra_context: Any
) -> Tuple[str, List[float]]: ...
def copy(self) -> Func: ...
class Value(Expression):
value: Any = ...
def __init__(
self, value: Any, output_field: Optional[Field] = ...
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[float]]: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Value: ...
def get_group_by_cols(self) -> List[Any]: ...
class DurationValue(Value):
output_field: DurationField
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class RawSQL(Expression):
output_field: Field
params: List[Any]
sql: str
def __init__(
self,
sql: str,
params: Union[List[int], List[str], Tuple],
output_field: None = ...,
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
def get_group_by_cols(self) -> List[RawSQL]: ...
def __hash__(self): ...
class Star(Expression):
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class Random(Expression):
output_field: Any = ...
def as_sql(self, compiler: Any, connection: Any): ...
class Col(Expression):
output_field: Field
contains_column_references: bool = ...
def __init__(
self,
alias: str,
target: Union[Field, str],
output_field: Optional[Field] = ...,
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
def relabeled_clone(
self, relabels: Union[Dict[str, str], OrderedDict]
) -> Col: ...
def get_group_by_cols(self) -> List[Col]: ...
def get_db_converters(
self, connection: DatabaseWrapper
) -> List[Callable]: ...
class Ref(Expression):
def __init__(self, refs: str, source: Expression) -> None: ...
def get_source_expressions(
self
) -> Union[List[Expression], List[SQLiteNumericMixin]]: ...
def set_source_expressions(self, exprs: Any) -> None: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: None = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Ref: ...
def relabeled_clone(self, relabels: Dict[Optional[str], str]) -> Ref: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
def get_group_by_cols(self): ...
class ExpressionList(Func):
template: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
class ExpressionWrapper(Expression):
expression: Any = ...
def __init__(
self, expression: Union[CombinedExpression, Q], output_field: Field
) -> None: ...
def set_source_expressions(
self, exprs: Union[List[CombinedExpression], List[WhereNode]]
) -> None: ...
def get_source_expressions(
self
) -> Union[List[CombinedExpression], List[Node]]: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class When(Expression):
template: str = ...
condition: Any = ...
result: Any = ...
def __init__(
self, condition: Any = ..., then: Any = ..., **lookups: Any
) -> None: ...
def get_source_expressions(self) -> List[Union[Expression, WhereNode]]: ...
def set_source_expressions(
self, exprs: List[Union[Expression, WhereNode]]
) -> None: ...
def get_source_fields(self) -> Union[List[None], List[Field]]: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> When: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
template: None = ...,
**extra_context: Any
) -> Tuple[str, List[Union[int, str]]]: ...
def get_group_by_cols(self) -> List[Col]: ...
class Case(Expression):
template: str = ...
case_joiner: str = ...
cases: Any = ...
default: Any = ...
extra: Any = ...
def __init__(
self,
*cases: Any,
default: Optional[Any] = ...,
output_field: Optional[Any] = ...,
**extra: Any
) -> None: ...
def get_source_expressions(self) -> List[Expression]: ...
def set_source_expressions(self, exprs: List[Expression]) -> None: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[Any]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Case: ...
def copy(self) -> Case: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
template: None = ...,
case_joiner: None = ...,
**extra_context: Any
) -> Tuple[str, List[Union[int, str]]]: ...
class Subquery(Expression):
template: str = ...
queryset: QuerySet = ...
extra: Dict[Any, Any] = ...
def __init__(
self,
queryset: QuerySet,
output_field: Optional[Field] = ...,
**extra: Any
) -> None: ...
def copy(self) -> Subquery: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[Any]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Subquery: ...
def get_source_expressions(self) -> List[Col]: ...
def relabeled_clone(self, change_map: OrderedDict) -> Subquery: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
template: None = ...,
**extra_context: Any
) -> Tuple[str, Tuple]: ...
class Exists(Subquery):
extra: Dict[Any, Any]
template: str = ...
negated: bool = ...
def __init__(
self, *args: Any, negated: bool = ..., **kwargs: Any
) -> None: ...
def __invert__(self) -> Exists: ...
def resolve_expression(
self, query: Query = ..., *args: Any, **kwargs: Any
) -> Exists: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
template: None = ...,
**extra_context: Any
) -> Tuple[str, Tuple]: ...
def as_oracle(
self,
compiler: Any,
connection: Any,
template: Optional[Any] = ...,
**extra_context: Any
): ...
class OrderBy(BaseExpression):
template: str = ...
nulls_first: bool = ...
nulls_last: bool = ...
descending: bool = ...
expression: Expression = ...
def __init__(
self,
expression: Combinable,
descending: bool = ...,
nulls_first: bool = ...,
nulls_last: bool = ...,
) -> None: ...
def set_source_expressions(self, exprs: List[Expression]) -> None: ...
def get_source_expressions(self) -> List[Combinable]: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
template: Optional[str] = ...,
**extra_context: Any
) -> Tuple[str, List[Union[int, str]]]: ...
def as_sqlite(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Union[int, str]]]: ...
def as_mysql(self, compiler: Any, connection: Any): ...
def get_group_by_cols(self): ...
def reverse_ordering(self) -> OrderBy: ...
def asc(self) -> None: ...
def desc(self) -> None: ...
class Window(Expression):
template: str = ...
contains_aggregate: bool = ...
contains_over_clause: bool = ...
filterable: bool = ...
partition_by: None = ...
order_by: None = ...
frame: None = ...
source_expression: Expression = ...
def __init__(
self,
expression: Aggregate,
partition_by: Optional[str] = ...,
order_by: Optional[Union[OrderBy, str]] = ...,
frame: None = ...,
output_field: None = ...,
) -> None: ...
def get_source_expressions(self): ...
def set_source_expressions(
self, exprs: List[Optional[DenseRank]]
) -> None: ...
def as_sql(
self,
compiler: Any,
connection: Any,
function: Optional[Any] = ...,
template: Optional[Any] = ...,
): ...
def get_group_by_cols(self) -> List[Any]: ...
class WindowFrame(Expression):
template: str = ...
start: None = ...
end: None = ...
def __init__(self, start: int = ..., end: Optional[int] = ...) -> None: ...
def set_source_expressions(self, exprs: Any) -> None: ...
def get_source_expressions(self): ...
def as_sql(self, compiler: Any, connection: Any): ...
def get_group_by_cols(self) -> List[Any]: ...
def window_frame_start_end(
self, connection: Any, start: Any, end: Any
) -> None: ...
class RowRange(WindowFrame):
end: None
start: int
frame_type: str = ...
def window_frame_start_end(self, connection: Any, start: Any, end: Any): ...
class ValueRange(WindowFrame):
end: int
start: None
frame_type: str = ...
def window_frame_start_end(self, connection: Any, start: Any, end: Any): ...

View File

@@ -0,0 +1,573 @@
from datetime import date, datetime, time, timedelta
from decimal import Context, Decimal
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from uuid import UUID
from django.core.validators import DecimalValidator
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.expressions import Col, CombinedExpression
from django.db.models.fields import reverse_related
from django.db.models.fields.files import FieldFile
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.query import QuerySet
from django.db.models.query_utils import RegisterLookupMixin
from django.db.models.sql.compiler import SQLCompiler, SQLInsertCompiler
from django.forms.fields import (BooleanField, DurationField, EmailField,
Field, FloatField, TypedMultipleChoiceField)
from django.utils.datastructures import DictWrapper
class Empty: ...
class NOT_PROVIDED: ...
BLANK_CHOICE_DASH: Any
class Field(RegisterLookupMixin):
empty_strings_allowed: bool = ...
empty_values: Any = ...
creation_counter: int = ...
auto_creation_counter: int = ...
default_validators: Any = ...
default_error_messages: Any = ...
system_check_deprecated_details: Any = ...
system_check_removed_details: Any = ...
hidden: bool = ...
many_to_many: Any = ...
many_to_one: Any = ...
one_to_many: Any = ...
one_to_one: Any = ...
related_model: Any = ...
description: Any = ...
name: Any = ...
verbose_name: Any = ...
primary_key: Any = ...
remote_field: Any = ...
is_relation: Any = ...
default: Any = ...
editable: Any = ...
serialize: Any = ...
unique_for_date: Any = ...
unique_for_month: Any = ...
unique_for_year: Any = ...
choices: Any = ...
help_text: Any = ...
db_index: Any = ...
db_column: Any = ...
auto_created: Any = ...
error_messages: Any = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
rel: Optional[ForeignObjectRel] = ...,
default: Any = ...,
editable: bool = ...,
serialize: bool = ...,
unique_for_date: None = ...,
unique_for_month: None = ...,
unique_for_year: None = ...,
choices: Optional[
Union[
List[List[Union[List[List[str]], str]]],
List[Tuple[Optional[int], str]],
List[Tuple[Union[int, str], int]],
Tuple[Tuple[Union[int, str], Union[int, str]]],
]
] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
auto_created: bool = ...,
validators: Union[List[Callable], Tuple] = ...,
error_messages: None = ...,
) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def get_col(
self,
alias: str,
output_field: Optional[
Union[Field, reverse_related.ForeignObjectRel]
] = ...,
) -> Col: ...
def cached_col(self) -> Col: ...
def select_format(
self, compiler: SQLCompiler, sql: str, params: List[Union[int, str]]
) -> Tuple[str, List[Union[int, str]]]: ...
def deconstruct(
self
) -> Tuple[
Optional[str], str, List[Any], Dict[str, List[Tuple[int, str]]]
]: ...
def clone(self) -> Field: ...
def __eq__(self, other: Field) -> bool: ...
def __lt__(self, other: Field) -> bool: ...
def __hash__(self) -> int: ...
def __deepcopy__(self, memodict: Dict[int, Dict[Any, Any]]) -> Field: ...
def __copy__(self) -> Field: ...
def __reduce__(self): ...
def get_pk_value_on_save(self, instance: Model) -> Optional[UUID]: ...
def to_python(self, value: FieldFile) -> FieldFile: ...
def validators(self) -> List[Callable]: ...
def run_validators(self, value: Any) -> None: ...
def validate(self, value: Any, model_instance: Optional[Model]) -> None: ...
def clean(self, value: Any, model_instance: Optional[Model]) -> Any: ...
def db_type_parameters(
self, connection: DatabaseWrapper
) -> DictWrapper: ...
def db_check(self, connection: DatabaseWrapper) -> None: ...
def db_type(self, connection: DatabaseWrapper) -> str: ...
def rel_db_type(self, connection: DatabaseWrapper) -> str: ...
def cast_db_type(self, connection: Any): ...
def db_parameters(
self, connection: DatabaseWrapper
) -> Dict[str, Optional[str]]: ...
def db_type_suffix(self, connection: DatabaseWrapper) -> Optional[str]: ...
def get_db_converters(
self, connection: DatabaseWrapper
) -> List[Callable]: ...
@property
def unique(self) -> bool: ...
@property
def db_tablespace(self) -> str: ...
concrete: Any = ...
def set_attributes_from_name(self, name: str) -> None: ...
model: Any = ...
def contribute_to_class(
self, cls: Type[Model], name: str, private_only: bool = ...
) -> None: ...
def get_filter_kwargs_for_object(self, obj: Any): ...
def get_attname(self) -> str: ...
def get_attname_column(self) -> Tuple[str, str]: ...
def get_internal_type(self) -> str: ...
def pre_save(self, model_instance: Model, add: bool) -> Any: ...
def get_prep_value(self, value: Any) -> Any: ...
def get_db_prep_value(
self, value: Any, connection: DatabaseWrapper, prepared: bool = ...
) -> Optional[Union[bytes, float, str]]: ...
def get_db_prep_save(
self, value: Any, connection: DatabaseWrapper
) -> Optional[Union[float, str]]: ...
def has_default(self) -> bool: ...
def get_default(self) -> Any: ...
def get_choices(
self,
include_blank: bool = ...,
blank_choice: List[Tuple[str, str]] = ...,
limit_choices_to: Optional[Dict[str, QuerySet]] = ...,
) -> List[
Tuple[
Union[int, str], Union[Tuple[Tuple[str, str], Tuple[str, str]], str]
]
]: ...
def value_to_string(self, obj: Model) -> str: ...
flatchoices: Any = ...
def save_form_data(
self, instance: Model, data: Optional[Union[date, Model, float, str]]
) -> None: ...
def formfield(
self,
form_class: Optional[Type[Field]] = ...,
choices_form_class: Optional[Type[TypedMultipleChoiceField]] = ...,
**kwargs: Any
) -> Field: ...
def value_from_object(self, obj: Model) -> Any: ...
class AutoField(Field):
description: Any = ...
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, Union[bool, str]]]: ...
def get_internal_type(self) -> str: ...
def to_python(self, value: Union[int, str]) -> int: ...
def rel_db_type(self, connection: DatabaseWrapper) -> str: ...
def validate(self, value: Any, model_instance: Any) -> None: ...
def get_db_prep_value(
self,
value: Union[int, str],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> Union[int, str]: ...
def get_prep_value(
self, value: Optional[Union[int, str]]
) -> Optional[int]: ...
def contribute_to_class(
self, cls: Type[Model], name: str, **kwargs: Any
) -> None: ...
def formfield(self, **kwargs: Any) -> None: ...
def __get__(self, instance, owner) -> int: ...
class BigAutoField(AutoField):
description: Any = ...
def get_internal_type(self) -> str: ...
def rel_db_type(self, connection: DatabaseWrapper) -> str: ...
class BooleanField(Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def get_internal_type(self) -> str: ...
def to_python(self, value: Optional[Union[bool, str]]) -> bool: ...
def get_prep_value(
self, value: Optional[Union[bool, str]]
) -> Optional[bool]: ...
def formfield(self, **kwargs: Any) -> BooleanField: ...
class CharField(Field):
description: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def cast_db_type(self, connection: Any): ...
def get_internal_type(self) -> str: ...
def to_python(
self, value: Optional[Union[Model, int, str]]
) -> Optional[str]: ...
def get_prep_value(
self, value: Optional[Union[Model, str]]
) -> Optional[str]: ...
def formfield(self, **kwargs: Any) -> Field: ...
def __get__(self, instance, owner) -> str: ...
class CommaSeparatedIntegerField(CharField):
default_validators: Any = ...
description: Any = ...
system_check_removed_details: Any = ...
class DateTimeCheckMixin:
def check(self, **kwargs: Any) -> List[Any]: ...
class DateField(DateTimeCheckMixin, Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
name: None = ...,
auto_now: bool = ...,
auto_now_add: bool = ...,
**kwargs: Any
) -> None: ...
def deconstruct(
self
) -> Tuple[
Optional[str], str, List[Any], Dict[str, Union[Callable, int, str]]
]: ...
def get_internal_type(self) -> str: ...
def to_python(
self, value: Optional[Union[date, str]]
) -> Optional[date]: ...
def pre_save(
self, model_instance: Model, add: bool
) -> Optional[Union[date, CombinedExpression]]: ...
def contribute_to_class(
self, cls: Type[Model], name: str, **kwargs: Any
) -> None: ...
def get_prep_value(
self, value: Optional[Union[date, str]]
) -> Optional[date]: ...
def get_db_prep_value(
self,
value: Optional[date],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> Optional[str]: ...
def value_to_string(self, obj: Model) -> str: ...
def formfield(self, **kwargs: Any) -> Field: ...
class DateTimeField(DateField):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def get_internal_type(self) -> str: ...
def to_python(
self, value: Optional[Union[datetime, str]]
) -> Optional[datetime]: ...
def pre_save(
self, model_instance: Model, add: bool
) -> Optional[Union[datetime, CombinedExpression]]: ...
def get_prep_value(
self, value: Optional[datetime]
) -> Optional[datetime]: ...
def get_db_prep_value(
self,
value: Optional[datetime],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> Optional[str]: ...
def value_to_string(self, obj: Model) -> str: ...
def formfield(self, **kwargs: Any) -> Field: ...
class DecimalField(Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def __init__(
self,
verbose_name: None = ...,
name: None = ...,
max_digits: Optional[int] = ...,
decimal_places: Optional[int] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def validators(self) -> List[DecimalValidator]: ...
def context(self) -> Context: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, int]]: ...
def get_internal_type(self) -> str: ...
def to_python(self, value: Optional[str]) -> Optional[Decimal]: ...
def get_db_prep_save(
self, value: Optional[str], connection: DatabaseWrapper
) -> Optional[str]: ...
def get_prep_value(self, value: None) -> None: ...
def formfield(self, **kwargs: Any): ...
class DurationField(Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def get_internal_type(self) -> str: ...
def to_python(self, value: str) -> timedelta: ...
def get_db_prep_value(
self, value: Any, connection: Any, prepared: bool = ...
): ...
def get_db_converters(self, connection: Any): ...
def value_to_string(self, obj: Model) -> str: ...
def formfield(self, **kwargs: Any) -> DurationField: ...
class EmailField(CharField):
default_validators: Any = ...
description: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, int]]: ...
def formfield(self, **kwargs: Any) -> EmailField: ...
class FilePathField(Field):
description: Any = ...
def __init__(
self,
verbose_name: Optional[Any] = ...,
name: Optional[Any] = ...,
path: str = ...,
match: Optional[Any] = ...,
recursive: bool = ...,
allow_files: bool = ...,
allow_folders: bool = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any): ...
def deconstruct(self): ...
def get_prep_value(self, value: Optional[str]) -> Optional[str]: ...
def get_internal_type(self): ...
class FloatField(Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def get_prep_value(self, value: Union[float, str]) -> float: ...
def get_internal_type(self) -> str: ...
def to_python(self, value: Union[float, str]) -> float: ...
def formfield(self, **kwargs: Any) -> FloatField: ...
class IntegerField(Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def check(self, **kwargs: Any) -> List[Any]: ...
def validators(self) -> List[Any]: ...
def get_prep_value(
self, value: Optional[Union[int, str]]
) -> Optional[int]: ...
def get_internal_type(self) -> str: ...
def to_python(self, value: Union[int, str]) -> int: ...
class BigIntegerField(IntegerField):
empty_strings_allowed: bool = ...
description: Any = ...
MAX_BIGINT: int = ...
def get_internal_type(self) -> str: ...
class IPAddressField(Field):
empty_strings_allowed: bool = ...
description: Any = ...
system_check_removed_details: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def deconstruct(self) -> Tuple[None, str, List[Any], Dict[str, bool]]: ...
def get_prep_value(self, value: Any): ...
def get_internal_type(self) -> str: ...
class GenericIPAddressField(Field):
empty_strings_allowed: bool = ...
description: Any = ...
default_error_messages: Any = ...
unpack_ipv4: Any = ...
protocol: Any = ...
def __init__(
self,
verbose_name: Optional[Any] = ...,
name: Optional[Any] = ...,
protocol: str = ...,
unpack_ipv4: bool = ...,
*args: Any,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any): ...
def deconstruct(self): ...
def get_internal_type(self): ...
def to_python(self, value: Union[Callable, int, str]) -> str: ...
def get_db_prep_value(
self,
value: Optional[str],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> Optional[str]: ...
def get_prep_value(self, value: Optional[str]) -> Optional[str]: ...
class NullBooleanField(BooleanField):
default_error_messages: Any = ...
description: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def deconstruct(self): ...
def get_internal_type(self): ...
class PositiveIntegerRelDbTypeMixin:
def rel_db_type(self, connection: Any): ...
class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField):
description: Any = ...
def get_internal_type(self) -> str: ...
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField):
description: Any = ...
def get_internal_type(self) -> str: ...
class SlugField(CharField):
default_validators: Any = ...
description: Any = ...
allow_unicode: Any = ...
def __init__(
self,
*args: Any,
max_length: int = ...,
db_index: bool = ...,
allow_unicode: bool = ...,
**kwargs: Any
) -> None: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, int]]: ...
def get_internal_type(self) -> str: ...
class SmallIntegerField(IntegerField):
description: Any = ...
def get_internal_type(self) -> str: ...
class TextField(Field):
description: Any = ...
def get_internal_type(self) -> str: ...
def to_python(
self, value: Optional[Union[Dict[Any, Any], int, str]]
) -> Optional[str]: ...
def get_prep_value(
self, value: Optional[Union[Dict[Any, Any], int, str]]
) -> Optional[str]: ...
class TimeField(DateTimeCheckMixin, Field):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
def __init__(
self,
verbose_name: None = ...,
name: None = ...,
auto_now: bool = ...,
auto_now_add: bool = ...,
**kwargs: Any
) -> None: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[Any, Any]]: ...
def get_internal_type(self) -> str: ...
def to_python(
self, value: Optional[Union[datetime, str]]
) -> Optional[time]: ...
def pre_save(
self, model_instance: Model, add: bool
) -> Optional[datetime]: ...
def get_prep_value(self, value: Optional[datetime]) -> Optional[time]: ...
def get_db_prep_value(
self,
value: Optional[datetime],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> Optional[str]: ...
def value_to_string(self, obj: Any): ...
class URLField(CharField):
default_validators: Any = ...
description: Any = ...
def __init__(
self, verbose_name: None = ..., name: None = ..., **kwargs: Any
) -> None: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, int]]: ...
class BinaryField(Field):
description: Any = ...
empty_values: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, bool]]: ...
def get_internal_type(self) -> str: ...
def get_placeholder(
self,
value: None,
compiler: SQLInsertCompiler,
connection: DatabaseWrapper,
) -> str: ...
def get_default(self) -> bytes: ...
def get_db_prep_value(
self,
value: Optional[bytes],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> None: ...
def value_to_string(self, obj: Any): ...
def to_python(self, value: Any): ...
class UUIDField(Field):
default_error_messages: Any = ...
description: str = ...
empty_strings_allowed: bool = ...
def __init__(self, verbose_name: None = ..., **kwargs: Any) -> None: ...
def deconstruct(
self
) -> Tuple[
Optional[str], str, List[Any], Dict[str, Union[Callable, bool]]
]: ...
def get_internal_type(self) -> str: ...
def get_db_prep_value(
self,
value: Optional[Union[Dict[Any, Any], List[Any]]],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> None: ...
def to_python(
self, value: Optional[Union[Dict[Any, Any], List[Any], UUID]]
) -> Optional[UUID]: ...

View File

@@ -0,0 +1,116 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.core.checks.messages import Error
from django.core.files.base import File
from django.core.files.images import ImageFile
from django.core.files.storage import FileSystemStorage, Storage
from django.db.models.base import Model
from django.db.models.fields import Field
from django.forms.fields import FileField, ImageField
class FieldFile(File):
instance: django.db.models.base.Model = ...
field: django.db.models.fields.files.FileField = ...
storage: django.core.files.storage.FileSystemStorage = ...
def __init__(
self, instance: Model, field: FileField, name: Optional[str]
) -> None: ...
def __eq__(self, other: Any) -> bool: ...
def __hash__(self): ...
file: Any = ...
@property
def path(self) -> str: ...
@property
def url(self) -> str: ...
@property
def size(self) -> int: ...
def open(self, mode: str = ...) -> FieldFile: ...
name: Optional[str] = ...
def save(self, name: str, content: File, save: bool = ...) -> None: ...
def delete(self, save: bool = ...) -> None: ...
@property
def closed(self) -> bool: ...
def close(self) -> None: ...
class FileDescriptor:
field: django.db.models.fields.files.FileField = ...
def __init__(self, field: FileField) -> None: ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> Union[FieldFile, FileDescriptor]: ...
def __set__(
self, instance: Model, value: Optional[Union[File, str]]
) -> None: ...
class FileField(Field):
attr_class: Any = ...
descriptor_class: Any = ...
description: Any = ...
storage: Any = ...
upload_to: Any = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
name: None = ...,
upload_to: Union[Callable, str] = ...,
storage: Optional[Storage] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, Union[bool, str]]]: ...
def get_internal_type(self) -> str: ...
def get_prep_value(self, value: Union[FieldFile, str]) -> str: ...
def pre_save(self, model_instance: Model, add: bool) -> FieldFile: ...
def contribute_to_class(
self, cls: Type[Model], name: str, **kwargs: Any
) -> None: ...
def generate_filename(
self, instance: Optional[Model], filename: str
) -> str: ...
def save_form_data(
self, instance: Model, data: Optional[Union[bool, File, str]]
) -> None: ...
def formfield(self, **kwargs: Any) -> FileField: ...
class ImageFileDescriptor(FileDescriptor):
field: django.db.models.fields.files.ImageField
def __set__(self, instance: Model, value: Optional[str]) -> None: ...
class ImageFieldFile(ImageFile, FieldFile):
field: django.db.models.fields.files.ImageField
instance: django.db.models.base.Model
name: Optional[str]
storage: django.core.files.storage.DefaultStorage
def delete(self, save: bool = ...) -> None: ...
class ImageField(FileField):
attr_class: Any = ...
descriptor_class: Any = ...
description: Any = ...
def __init__(
self,
verbose_name: None = ...,
name: None = ...,
width_field: Optional[str] = ...,
height_field: Optional[str] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def deconstruct(
self
) -> Tuple[
Optional[str],
str,
List[Any],
Dict[str, Union[Callable, bool, FileSystemStorage, str]],
]: ...
def contribute_to_class(
self, cls: Type[Model], name: str, **kwargs: Any
) -> None: ...
def update_dimension_fields(
self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any
) -> None: ...
def formfield(self, **kwargs: Any) -> ImageField: ...

View File

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

View File

@@ -0,0 +1,7 @@
from typing import Any, Optional
from django.db.models import fields
class OrderWrt(fields.IntegerField):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...

View File

@@ -0,0 +1,325 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from uuid import UUID
from django.core.checks.messages import Error, 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.related_lookups import RelatedIsNull
from django.db.models.fields.reverse_related import (ForeignObjectRel,
ManyToManyRel,
ManyToOneRel, OneToOneRel)
from django.db.models.lookups import FieldGetDbPrepValueMixin
from django.db.models.query import QuerySet
from django.db.models.query_utils import PathInfo, Q
from django.db.models.sql.where import WhereNode
from django.forms.fields import Field
from django.forms.models import ModelChoiceField, ModelMultipleChoiceField
from . import Field
from .mixins import FieldCacheMixin
from .related_descriptors import (ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
ForwardOneToOneDescriptor as ForwardOneToOneDescriptor,
ManyToManyDescriptor as ManyToManyDescriptor,
ReverseManyToOneDescriptor as ReverseManyToOneDescriptor,
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor)
from .related_lookups import (RelatedExact, RelatedGreaterThan,
RelatedGreaterThanOrEqual, RelatedIn,
RelatedIsNull, RelatedLessThan,
RelatedLessThanOrEqual)
from .reverse_related import (ForeignObjectRel, ManyToManyRel, ManyToOneRel,
OneToOneRel)
RECURSIVE_RELATIONSHIP_CONSTANT: str
def resolve_relation(
scope_model: Type[Model], relation: Union[Type[Model], str]
) -> Union[Type[Model], str]: ...
def lazy_related_operation(
function: Callable, model: Type[Model], *related_models: Any, **kwargs: Any
) -> None: ...
class RelatedField(FieldCacheMixin, Field):
one_to_many: bool = ...
one_to_one: bool = ...
many_to_many: bool = ...
many_to_one: bool = ...
def related_model(self) -> Union[Type[Model], str]: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def db_type(self, connection: DatabaseWrapper) -> None: ...
opts: Any = ...
def contribute_to_class(
self,
cls: Type[Model],
name: str,
private_only: bool = ...,
**kwargs: Any
) -> None: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, str]]: ...
def get_forward_related_filter(
self, obj: Model
) -> Dict[str, Union[int, UUID]]: ...
def get_reverse_related_filter(self, obj: Model) -> Q: ...
@property
def swappable_setting(self) -> Optional[str]: ...
name: Any = ...
verbose_name: Any = ...
def set_attributes_from_rel(self) -> None: ...
def do_related_class(
self, other: Type[Model], cls: Type[Model]
) -> None: ...
def get_limit_choices_to(self) -> Dict[str, int]: ...
def formfield(self, **kwargs: Any) -> Field: ...
def related_query_name(self) -> str: ...
@property
def target_field(self) -> Field: ...
def get_cache_name(self) -> str: ...
class ForeignObject(RelatedField):
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ...
one_to_one: bool = ...
requires_unique_target: bool = ...
related_accessor_class: Any = ...
forward_related_accessor_class: Any = ...
rel_class: Any = ...
from_fields: Any = ...
to_fields: Any = ...
swappable: Any = ...
def __init__(
self,
to: Union[Type[Model], str],
on_delete: Callable,
from_fields: Union[List[str], Tuple[str, str]],
to_fields: Union[List[None], List[str], Tuple[str, str]],
rel: Optional[ForeignObjectRel] = ...,
related_name: None = ...,
related_query_name: None = ...,
limit_choices_to: None = ...,
parent_link: bool = ...,
swappable: bool = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def deconstruct(
self
) -> Tuple[
Optional[str],
str,
List[Any],
Dict[str, Any],
]: ...
def resolve_related_fields(self) -> List[Tuple[Field, Field]]: ...
@property
def related_fields(self) -> List[Tuple[Field, Field]]: ...
@property
def reverse_related_fields(self) -> List[Tuple[Field, Field]]: ...
@property
def local_related_fields(self) -> Tuple[Field]: ...
@property
def foreign_related_fields(self) -> Tuple[Field]: ...
def get_local_related_value(
self, instance: Model
) -> Tuple[Optional[int]]: ...
def get_foreign_related_value(
self, instance: Model
) -> Tuple[Optional[int]]: ...
@staticmethod
def get_instance_value_for_fields(
instance: Model, fields: Tuple[Field]
) -> Tuple[Optional[int]]: ...
def get_attname_column(self) -> Tuple[str, None]: ...
def get_joining_columns(
self, reverse_join: bool = ...
) -> Tuple[Tuple[str, str]]: ...
def get_reverse_joining_columns(self) -> Tuple: ...
def get_extra_descriptor_filter(
self, instance: Model
) -> Dict[Any, Any]: ...
def get_extra_restriction(
self, where_class: Type[WhereNode], alias: str, related_alias: str
) -> None: ...
def get_path_info(
self, filtered_relation: None = ...
) -> List[PathInfo]: ...
def get_reverse_path_info(self, filtered_relation: Optional[Any] = ...): ...
@classmethod
def get_lookups(
cls
) -> Dict[str, Type[Union[RelatedIsNull, FieldGetDbPrepValueMixin]]]: ...
def contribute_to_class(
self,
cls: Type[Model],
name: str,
private_only: bool = ...,
**kwargs: Any
) -> None: ...
def contribute_to_related_class(
self, cls: Type[Model], related: ForeignObjectRel
) -> None: ...
class ForeignKey(ForeignObject):
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ...
one_to_one: bool = ...
rel_class: Any = ...
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
description: Any = ...
db_constraint: Any = ...
def __init__(
self,
to: Union[Type[Model], str],
on_delete: Callable,
related_name: Optional[str] = ...,
related_query_name: None = ...,
limit_choices_to: Optional[
Union[Callable, Dict[str, Union[int, str]]]
] = ...,
parent_link: bool = ...,
to_field: Optional[str] = ...,
db_constraint: bool = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Warning]: ...
def deconstruct(
self
) -> Tuple[
Optional[str],
str,
List[Any],
Dict[str, Union[Callable, Dict[str, Union[int, str]], str]],
]: ...
def to_python(self, value: Union[int, str]) -> int: ...
@property
def target_field(self) -> Field: ...
def get_reverse_path_info(
self, filtered_relation: None = ...
) -> List[PathInfo]: ...
def validate(
self, value: Union[int, str], model_instance: Model
) -> None: ...
def get_attname(self) -> str: ...
def get_attname_column(self) -> Tuple[str, str]: ...
def get_default(self) -> Optional[int]: ...
def get_db_prep_save(
self,
value: Optional[Union[int, str, UUID]],
connection: DatabaseWrapper,
) -> Optional[Union[int, str]]: ...
def get_db_prep_value(
self,
value: Union[int, str, UUID],
connection: DatabaseWrapper,
prepared: bool = ...,
) -> Union[int, str]: ...
def contribute_to_related_class(
self, cls: Type[Model], related: ManyToOneRel
) -> None: ...
def formfield(
self, *, using: Optional[Any] = ..., **kwargs: Any
) -> ModelChoiceField: ...
def db_check(self, connection: DatabaseWrapper) -> List[Any]: ...
def db_type(self, connection: DatabaseWrapper) -> str: ...
def db_parameters(
self, connection: DatabaseWrapper
) -> Dict[str, Union[List[Any], str]]: ...
def convert_empty_strings(
self, value: Any, expression: Any, connection: Any
): ...
def get_db_converters(self, connection: DatabaseWrapper) -> List[Any]: ...
def get_col(
self,
alias: str,
output_field: Optional[Union[Field, OneToOneRel]] = ...,
) -> Col: ...
class OneToOneField(ForeignKey):
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ...
one_to_one: bool = ...
related_accessor_class: Any = ...
forward_related_accessor_class: Any = ...
rel_class: Any = ...
description: Any = ...
def __init__(
self,
to: Union[Type[Model], str],
on_delete: Callable,
to_field: Optional[str] = ...,
**kwargs: Any
) -> None: ...
def deconstruct(
self
) -> Tuple[
Optional[str], str, List[Any], Dict[str, Union[Callable, bool, str]]
]: ...
def formfield(self, **kwargs: Any) -> None: ...
def save_form_data(
self, instance: Model, data: Optional[Model]
) -> None: ...
def create_many_to_many_intermediary_model(field: Any, klass: Any): ...
class ManyToManyField(RelatedField):
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ...
one_to_one: bool = ...
rel_class: Any = ...
description: Any = ...
has_null_arg: Any = ...
db_table: Any = ...
swappable: Any = ...
def __init__(
self,
to: Union[Type[Model], str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Callable] = ...,
symmetrical: Optional[bool] = ...,
through: Optional[str] = ...,
through_fields: Optional[Tuple[str, str]] = ...,
db_constraint: bool = ...,
db_table: None = ...,
swappable: bool = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def deconstruct(
self
) -> Tuple[Optional[str], str, List[Any], Dict[str, str]]: ...
def get_path_info(
self, filtered_relation: None = ...
) -> List[PathInfo]: ...
def get_reverse_path_info(
self, filtered_relation: None = ...
) -> List[PathInfo]: ...
m2m_db_table: Any = ...
def contribute_to_class(
self, cls: Type[Model], name: str, **kwargs: Any
) -> None: ...
m2m_column_name: Any = ...
m2m_reverse_name: Any = ...
m2m_field_name: Any = ...
m2m_reverse_field_name: Any = ...
m2m_target_field_name: Any = ...
m2m_reverse_target_field_name: Any = ...
def contribute_to_related_class(
self, cls: Type[Model], related: ManyToManyRel
) -> None: ...
def set_attributes_from_rel(self) -> None: ...
def value_from_object(self, obj: Model) -> List[Model]: ...
def save_form_data(self, instance: Model, data: QuerySet) -> None: ...
def formfield(
self, *, using: Optional[Any] = ..., **kwargs: Any
) -> ModelMultipleChoiceField: ...
def db_check(self, connection: Any): ...
def db_type(self, connection: Any): ...
def db_parameters(self, connection: DatabaseWrapper) -> Dict[str, None]: ...

View File

@@ -0,0 +1,110 @@
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Generic, TypeVar
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.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignObject, RelatedField, OneToOneField
from django.db.models.fields.reverse_related import ManyToManyRel, OneToOneRel
from django.db.models.query import QuerySet
_T = TypeVar('_T')
class ForwardManyToOneDescriptor:
RelatedObjectDoesNotExist: Type[ObjectDoesNotExist]
field: ForeignObject = ...
def __init__(self, field_with_rel: ForeignObject) -> None: ...
def is_cached(self, instance: Model) -> bool: ...
def get_queryset(self, **hints: Any) -> QuerySet: ...
def get_prefetch_queryset(
self, instances: List[Model], queryset: Optional[QuerySet] = ...
) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ...
def get_object(self, instance: Model) -> Model: ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> Optional[Union[Model, ForwardManyToOneDescriptor]]: ...
def __set__(
self, instance: Model, value: Optional[Union[Model, F]]
) -> None: ...
def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ...
class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor):
RelatedObjectDoesNotExist: Type[ObjectDoesNotExist]
field: OneToOneField
def get_object(self, instance: Model) -> Model: ...
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
class ReverseOneToOneDescriptor:
RelatedObjectDoesNotExist: Type[ObjectDoesNotExist]
related: OneToOneRel = ...
def __init__(self, related: OneToOneRel) -> None: ...
def is_cached(self, instance: Model) -> bool: ...
def get_queryset(self, **hints: Any) -> QuerySet: ...
def get_prefetch_queryset(
self, instances: List[Model], queryset: Optional[QuerySet] = ...
) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> Union[Model, ReverseOneToOneDescriptor]: ...
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
def __reduce__(self) -> Tuple[Callable, Tuple[Type[Model], str]]: ...
class ReverseManyToOneDescriptor:
rel: FieldCacheMixin = ...
field: FieldCacheMixin = ...
def __init__(self, rel: FieldCacheMixin) -> None: ...
def related_manager_cls(self): ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> ReverseManyToOneDescriptor: ...
def __set__(self, instance: Model, value: List[Model]) -> Any: ...
def create_reverse_many_to_one_manager(superclass: Any, rel: Any): ...
class ManyToManyDescriptor(ReverseManyToOneDescriptor):
field: RelatedField
rel: ManyToManyRel
reverse: bool = ...
def __init__(self, rel: ManyToManyRel, reverse: bool = ...) -> None: ...
@property
def through(self) -> Type[Model]: ...
def related_manager_cls(self): ...
class _ForwardManyToManyManager(Generic[_T]):
def all(self) -> QuerySet: ...
def create_forward_many_to_many_manager(
superclass: Any, rel: Any, reverse: Any
) -> _ForwardManyToManyManager: ...

View File

@@ -0,0 +1,74 @@
from collections import OrderedDict
from typing import Any, List, Optional, Tuple, Type, Union
from uuid import UUID
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.related import ForeignObject
from django.db.models.lookups import (BuiltinLookup, Exact, GreaterThan,
GreaterThanOrEqual, In, IsNull, LessThan,
LessThanOrEqual)
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
class MultiColSource:
alias: str
field: django.db.models.fields.related.ForeignObject
sources: Tuple[django.db.models.fields.Field, django.db.models.fields.Field]
targets: Tuple[django.db.models.fields.Field, django.db.models.fields.Field]
contains_aggregate: bool = ...
output_field: django.db.models.fields.related.ForeignObject = ...
def __init__(
self,
alias: str,
targets: Tuple[Field, Field],
sources: Tuple[Field, Field],
field: related.ForeignObject,
) -> None: ...
def relabeled_clone(self, relabels: OrderedDict) -> MultiColSource: ...
def get_lookup(self, lookup: str) -> Type[BuiltinLookup]: ...
def get_normalized_value(
value: Any, lhs: Union[Col, MultiColSource]
) -> Tuple[None]: ...
class RelatedIn(In):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: Union[
django.db.models.expressions.Col,
django.db.models.fields.related_lookups.MultiColSource,
]
rhs: Union[
List[django.db.models.base.Model],
List[int],
List[uuid.UUID],
Set[django.contrib.contenttypes.models.ContentType],
Set[int],
Set[str],
Set[uuid.UUID],
django.db.models.sql.query.Query,
] = ...
def get_prep_lookup(
self
) -> Union[List[Model], List[int], List[str], List[UUID], Query]: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class RelatedLookupMixin:
rhs: Any = ...
def get_prep_lookup(self) -> Any: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Union[int, str]]]: ...
class RelatedExact(RelatedLookupMixin, Exact): ...
class RelatedLessThan(RelatedLookupMixin, LessThan): ...
class RelatedGreaterThan(RelatedLookupMixin, GreaterThan): ...
class RelatedGreaterThanOrEqual(RelatedLookupMixin, GreaterThanOrEqual): ...
class RelatedLessThanOrEqual(RelatedLookupMixin, LessThanOrEqual): ...
class RelatedIsNull(RelatedLookupMixin, IsNull): ...

View File

@@ -0,0 +1,180 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.db.models.base import Model
from django.db.models.fields import AutoField, Field
from django.db.models.fields.related import (ForeignKey, OneToOneField,
RelatedField)
from django.db.models.lookups import BuiltinLookup, StartsWith
from django.db.models.query_utils import FilteredRelation, PathInfo, Q
from django.db.models.sql.where import WhereNode
from .mixins import FieldCacheMixin
class ForeignObjectRel(FieldCacheMixin):
hidden: bool
many_to_many: bool
many_to_one: bool
name: str
one_to_many: bool
one_to_one: bool
related_model: Type[django.db.models.base.Model]
auto_created: bool = ...
concrete: bool = ...
editable: bool = ...
is_relation: bool = ...
null: bool = ...
field: django.db.models.fields.related.ForeignObject = ...
model: Union[Type[django.db.models.base.Model], str] = ...
related_name: Optional[str] = ...
related_query_name: None = ...
limit_choices_to: Dict[Any, Any] = ...
parent_link: bool = ...
on_delete: Callable = ...
symmetrical: bool = ...
multiple: bool = ...
def __init__(
self,
field: RelatedField,
to: Union[Type[Model], str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[
Union[Callable, Dict[str, Union[int, str]], Q]
] = ...,
parent_link: bool = ...,
on_delete: Optional[Callable] = ...,
) -> None: ...
def hidden(self) -> bool: ...
def name(self) -> str: ...
@property
def remote_field(self) -> RelatedField: ...
@property
def target_field(self) -> AutoField: ...
def related_model(self) -> Type[Model]: ...
def many_to_many(self) -> bool: ...
def many_to_one(self) -> bool: ...
def one_to_many(self) -> bool: ...
def one_to_one(self) -> bool: ...
def get_lookup(self, lookup_name: str) -> Type[BuiltinLookup]: ...
def get_internal_type(self) -> str: ...
@property
def db_type(self) -> Callable: ...
def get_choices(
self,
include_blank: bool = ...,
blank_choice: List[Tuple[str, str]] = ...,
) -> List[Tuple[int, str]]: ...
def is_hidden(self) -> bool: ...
def get_joining_columns(self) -> Tuple: ...
def get_extra_restriction(
self, where_class: Type[WhereNode], alias: str, related_alias: str
) -> Optional[Union[StartsWith, WhereNode]]: ...
field_name: None = ...
def set_field_name(self) -> None: ...
def get_accessor_name(
self, model: Optional[Type[Model]] = ...
) -> Optional[str]: ...
def get_path_info(
self, filtered_relation: Optional[FilteredRelation] = ...
) -> List[PathInfo]: ...
def get_cache_name(self) -> str: ...
class ManyToOneRel(ForeignObjectRel):
field: django.db.models.fields.related.ForeignKey
hidden: bool
limit_choices_to: Union[
Callable, Dict[str, Union[int, str]], django.db.models.query_utils.Q
]
many_to_many: bool
many_to_one: bool
model: Union[Type[django.db.models.base.Model], str]
multiple: bool
name: str
on_delete: Callable
one_to_many: bool
one_to_one: bool
parent_link: bool
related_model: Type[django.db.models.base.Model]
related_name: Optional[str]
related_query_name: Optional[str]
symmetrical: bool
field_name: Optional[str] = ...
def __init__(
self,
field: ForeignKey,
to: Union[Type[Model], str],
field_name: Optional[str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[
Union[Callable, Dict[str, Union[int, str]], Q]
] = ...,
parent_link: bool = ...,
on_delete: Callable = ...,
) -> None: ...
def get_related_field(self) -> Field: ...
def set_field_name(self) -> None: ...
class OneToOneRel(ManyToOneRel):
field: django.db.models.fields.related.OneToOneField
field_name: Optional[str]
hidden: bool
limit_choices_to: Dict[str, str]
many_to_many: bool
many_to_one: bool
model: Union[Type[django.db.models.base.Model], str]
name: str
on_delete: Callable
one_to_many: bool
one_to_one: bool
parent_link: bool
related_model: Type[django.db.models.base.Model]
related_name: Optional[str]
related_query_name: Optional[str]
symmetrical: bool
multiple: bool = ...
def __init__(
self,
field: OneToOneField,
to: Union[Type[Model], str],
field_name: Optional[str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Dict[str, str]] = ...,
parent_link: bool = ...,
on_delete: Callable = ...,
) -> None: ...
class ManyToManyRel(ForeignObjectRel):
field: django.db.models.fields.related.RelatedField
field_name: None
hidden: bool
limit_choices_to: Union[Callable, Dict[str, str]]
model: Union[Type[django.db.models.base.Model], str]
multiple: bool
name: str
on_delete: None
one_to_many: bool
one_to_one: bool
parent_link: bool
related_model: Type[django.db.models.base.Model]
related_name: Optional[str]
related_query_name: Optional[str]
through: Optional[Union[Type[django.db.models.base.Model], str]] = ...
through_fields: Optional[Tuple[str, str]] = ...
symmetrical: bool = ...
db_constraint: bool = ...
def __init__(
self,
field: RelatedField,
to: Union[Type[Model], str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Callable, Dict[str, str]]] = ...,
symmetrical: bool = ...,
through: Optional[Union[Type[Model], str]] = ...,
through_fields: Optional[Tuple[str, str]] = ...,
db_constraint: bool = ...,
) -> None: ...
def get_related_field(self) -> Field: ...

View File

@@ -0,0 +1,70 @@
from datetime import date, datetime
from decimal import Decimal
from typing import Any, List, Optional, Tuple, Union
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models import Func
from django.db.models.expressions import Value
from django.db.models.fields import Field
from django.db.models.sql.compiler import SQLCompiler
class Cast(Func):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
template: str = ...
def __init__(
self, expression: Union[date, Decimal, Value, str], output_field: Field
) -> None: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context: Any
) -> Tuple[str, Union[List[date], List[Decimal]]]: ...
def as_mysql(self, compiler: Any, connection: Any): ...
def as_postgresql(self, compiler: Any, connection: Any): ...
class Coalesce(Func):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
def as_oracle(self, compiler: Any, connection: Any): ...
class Greatest(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
def as_sqlite(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[datetime]]: ...
class Least(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
def as_sqlite(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[datetime]]: ...

View File

@@ -0,0 +1,280 @@
from datetime import datetime
from typing import Any, List, Optional, Set, Tuple, Union, Callable, Dict
from django.db import models
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models import Func, Transform
from django.db.models.expressions import Col, Expression, Combinable
from django.db.models.fields import Field
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
class TimezoneMixin:
tzinfo: Any = ...
def get_tzname(self) -> Optional[str]: ...
class Extract(TimezoneMixin, Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
lookup_name: Optional[str] = ...
output_field: Any = ...
tzinfo: None = ...
def __init__(
self,
expression: Union[Expression, str],
lookup_name: Optional[str] = ...,
tzinfo: None = ...,
**extra: Any
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[Any]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Extract: ...
class ExtractYear(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractMonth(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractDay(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractWeek(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractWeekDay(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractQuarter(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractHour(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractMinute(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class ExtractSecond(Extract):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
lookup_name: str = ...
class Now(Func):
contains_aggregate: bool
contains_over_clause: bool
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Any]
template: str = ...
output_field: Any = ...
def as_postgresql(self, compiler: Any, connection: Any): ...
class TruncBase(TimezoneMixin, Transform):
kind: Any = ...
tzinfo: Any = ...
def __init__(
self,
expression: Union[Col, str],
output_field: Optional[Field] = ...,
tzinfo: None = ...,
**extra: Any
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[Any]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> TruncBase: ...
def convert_value(
self,
value: datetime,
expression: models.functions.TruncBase,
connection: DatabaseWrapper,
) -> datetime: ...
class Trunc(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: Union[
models.fields.DateTimeCheckMixin,
models.fields.IntegerField,
]
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
def __init__(
self,
expression: str,
kind: str,
output_field: Optional[Field] = ...,
tzinfo: None = ...,
**extra: Any
) -> None: ...
class TruncYear(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncQuarter(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncMonth(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncWeek(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncDay(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncDate(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
lookup_name: str = ...
output_field: models.fields.TimeField = ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class TruncTime(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
lookup_name: str = ...
output_field: models.fields.DateField = ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class TruncHour(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncMinute(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...
class TruncSecond(TruncBase):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: models.fields.DateTimeCheckMixin
source_expressions: List[Combinable]
tzinfo: None
kind: str = ...

View File

@@ -0,0 +1,267 @@
from typing import Any, List, Optional, Tuple, Union, Dict, Callable
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models import Func, Transform
from django.db.models.expressions import Combinable, Expression, Value
from django.db.models.sql.compiler import SQLCompiler
class BytesToCharFieldConversionMixin:
def convert_value(
self,
value: str,
expression: BytesToCharFieldConversionMixin,
connection: DatabaseWrapper,
) -> str: ...
class Chr(Transform):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.IntegerField
source_expressions: List[django.db.models.expressions.Expression]
function: str = ...
lookup_name: str = ...
def as_mysql(self, compiler: Any, connection: Any): ...
def as_oracle(self, compiler: Any, connection: Any): ...
def as_sqlite(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context: Any
) -> Tuple[str, List[int]]: ...
class ConcatPair(Func):
contains_aggregate: bool
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def as_sqlite(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
def as_mysql(self, compiler: Any, connection: Any): ...
def coalesce(self) -> ConcatPair: ...
class Concat(Func):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.functions.text.ConcatPair]
function: Any = ...
template: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
class Left(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
arity: int = ...
def __init__(
self, expression: str, length: Union[Value, int], **extra: Any
) -> None: ...
def get_substr(self) -> Substr: ...
def use_substr(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context: Any
) -> Tuple[str, List[int]]: ...
as_oracle: Any = ...
as_sqlite: Any = ...
class Length(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
output_field: Any = ...
def as_mysql(self, compiler: Any, connection: Any): ...
class Lower(Transform):
contains_aggregate: bool
contains_column_references: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
class LPad(BytesToCharFieldConversionMixin, Func):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(
self,
expression: str,
length: Union[Length, int],
fill_text: Value = ...,
**extra: Any
) -> None: ...
class LTrim(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
class Ord(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
output_field: Any = ...
def as_mysql(
self, compiler: Any, connection: Any, **extra_context: Any
): ...
def as_sqlite(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
**extra_context: Any
) -> Tuple[str, List[Any]]: ...
class Repeat(BytesToCharFieldConversionMixin, Func):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(
self,
expression: Union[Value, str],
number: Union[Length, int],
**extra: Any
) -> None: ...
def as_oracle(
self, compiler: Any, connection: Any, **extra_context: Any
): ...
class Replace(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(
self,
expression: Combinable,
text: Value,
replacement: Value = ...,
**extra: Any
) -> None: ...
class Right(Left):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def get_substr(self) -> Substr: ...
class RPad(LPad):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
class RTrim(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
class StrIndex(Func):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
arity: int = ...
output_field: Any = ...
def as_postgresql(self, compiler: Any, connection: Any): ...
class Substr(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
def __init__(
self,
expression: Union[Expression, str],
pos: Union[Expression, int],
length: Optional[Union[Value, int]] = ...,
**extra: Any
) -> None: ...
def as_sqlite(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Union[int, str]]]: ...
def as_oracle(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[int]]: ...
class Trim(Transform):
contains_aggregate: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.CharField
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...
class Upper(Transform):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: django.db.models.fields.Field
source_expressions: List[django.db.models.expressions.Combinable]
function: str = ...
lookup_name: str = ...

View File

@@ -0,0 +1,81 @@
from typing import Any, Optional, Dict, List
from django.db.models import Func
class CumeDist(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class DenseRank(Func):
extra: Dict[Any, Any]
source_expressions: List[Any]
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class FirstValue(Func):
arity: int = ...
function: str = ...
name: str = ...
window_compatible: bool = ...
class LagLeadFunction(Func):
window_compatible: bool = ...
def __init__(
self,
expression: Optional[str],
offset: int = ...,
default: None = ...,
**extra: Any
) -> Any: ...
class Lag(LagLeadFunction):
function: str = ...
name: str = ...
class LastValue(Func):
arity: int = ...
function: str = ...
name: str = ...
window_compatible: bool = ...
class Lead(LagLeadFunction):
function: str = ...
name: str = ...
class NthValue(Func):
function: str = ...
name: str = ...
window_compatible: bool = ...
def __init__(
self, expression: Optional[str], nth: int = ..., **extra: Any
) -> Any: ...
class Ntile(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
def __init__(self, num_buckets: int = ..., **extra: Any) -> Any: ...
class PercentRank(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class Rank(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class RowNumber(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...

View File

@@ -0,0 +1,38 @@
from typing import Any, Dict, List, Optional, Tuple, Type, Union
from django.db.backends.ddl_references import Statement
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.models.base import Model
class Index:
model: Type[django.db.models.base.Model]
suffix: str = ...
max_name_length: int = ...
fields: List[str] = ...
fields_orders: List[Tuple[str, str]] = ...
name: str = ...
db_tablespace: Optional[str] = ...
def __init__(
self,
*,
fields: Any = ...,
name: Optional[Any] = ...,
db_tablespace: Optional[Any] = ...
) -> None: ...
def check_name(self) -> List[str]: ...
def create_sql(
self,
model: Type[Model],
schema_editor: DatabaseSchemaEditor,
using: str = ...,
) -> Statement: ...
def remove_sql(
self, model: Type[Model], schema_editor: DatabaseSchemaEditor
) -> str: ...
def deconstruct(
self
) -> Tuple[str, Tuple, Dict[str, Union[List[str], str]]]: ...
def clone(self) -> Index: ...
def set_name_with_model(self, model: Type[Model]) -> None: ...
def __eq__(self, other: Index) -> bool: ...

View File

@@ -0,0 +1,336 @@
from collections import OrderedDict
from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple, Type, Union, Iterable
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models import expressions, lookups
from django.db.models.expressions import (Col, Combinable, Expression, Func,
Ref)
from django.db.models.fields import TextField, related_lookups
from django.db.models.query_utils import RegisterLookupMixin
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
from django.utils.datastructures import OrderedSet
from django.utils.safestring import SafeText
class Lookup:
lookup_name: Any = ...
prepare_rhs: bool = ...
can_use_none_as_rhs: bool = ...
rhs: Any = ...
bilateral_transforms: Any = ...
def __init__(
self,
lhs: Union[Expression, TextField, related_lookups.MultiColSource],
rhs: Any,
) -> None: ...
def apply_bilateral_transforms(self, value: Expression) -> Transform: ...
def batch_process_rhs(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
rhs: Optional[OrderedSet] = ...,
) -> Tuple[List[str], List[str]]: ...
def get_source_expressions(self) -> List[Expression]: ...
lhs: Any = ...
def set_source_expressions(self, new_exprs: List[Ref]) -> None: ...
def get_prep_lookup(self) -> Any: ...
def get_db_prep_lookup(
self, value: Union[int, str], connection: DatabaseWrapper
) -> Tuple[str, List[SafeText]]: ...
def process_lhs(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
lhs: Optional[Col] = ...,
) -> Tuple[str, List[Union[int, str]]]: ...
def process_rhs(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Union[List[Union[int, str]], Tuple[int, int]]]: ...
def rhs_is_direct_value(self) -> bool: ...
def relabeled_clone(
self, relabels: Union[Dict[Optional[str], str], OrderedDict]
) -> Union[BuiltinLookup, FieldGetDbPrepValueMixin]: ...
def get_group_by_cols(self) -> List[Expression]: ...
def as_sql(self, compiler: Any, connection: Any) -> None: ...
def contains_aggregate(self) -> bool: ...
def contains_over_clause(self) -> bool: ...
@property
def is_summary(self): ...
class Transform(RegisterLookupMixin, Func):
bilateral: bool = ...
arity: int = ...
@property
def lhs(self) -> Expression: ...
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...
class BuiltinLookup(Lookup):
def process_lhs(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
lhs: Optional[Col] = ...,
) -> Tuple[str, List[Union[int, str]]]: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[float]]: ...
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
class FieldGetDbPrepValueMixin:
get_db_prep_lookup_value_is_iterable: bool = ...
def get_db_prep_lookup(
self, value: Any, connection: DatabaseWrapper
) -> Tuple[str, List[float]]: ...
class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
get_db_prep_lookup_value_is_iterable: bool = ...
def get_prep_lookup(
self
) -> Iterable[Any]: ...
def process_rhs(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[Union[Tuple[str, str], str], Tuple]: ...
def resolve_expression_parameter(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
sql: str,
param: Optional[Union[Combinable, int, str]],
) -> Tuple[str, List[None]]: ...
def batch_process_rhs(
self,
compiler: SQLCompiler,
connection: DatabaseWrapper,
rhs: Optional[OrderedSet] = ...,
) -> Tuple[Tuple[str], Tuple]: ...
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup):
bilateral_transforms: List[Type[lookups.Transform]]
contains_aggregate: bool
contains_over_clause: bool
lhs: Expression
rhs: Any
lookup_name: str = ...
def process_rhs(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Union[List[str], Tuple[int, int]]]: ...
class IExact(BuiltinLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: Optional[Union[expressions.Col, str]]
lookup_name: str = ...
prepare_rhs: bool = ...
def process_rhs(
self, qn: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: Expression
rhs: Any
lookup_name: str = ...
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: Expression
rhs: Any
lookup_name: str = ...
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: Expression
rhs: Any
lookup_name: str = ...
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup):
bilateral_transforms: List[Type[lookups.Transform]]
contains_aggregate: bool
contains_over_clause: bool
lhs: Expression
rhs: Any
lookup_name: str = ...
class IntegerFieldFloatRounding:
rhs: Any = ...
def get_prep_lookup(self) -> Union[Combinable, Query, int]: ...
class IntegerGreaterThanOrEqual(
IntegerFieldFloatRounding, GreaterThanOrEqual
): ...
class IntegerLessThan(IntegerFieldFloatRounding, LessThan): ...
class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
bilateral_transforms: List[Type[lookups.Transform]]
contains_aggregate: bool
lhs: Expression
rhs: Any
lookup_name: str = ...
def process_rhs(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Tuple]: ...
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Union[int, str]]]: ...
def split_parameter_list_as_sql(self, compiler: Any, connection: Any): ...
class PatternLookup(BuiltinLookup):
param_pattern: str = ...
prepare_rhs: bool = ...
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
def process_rhs(
self, qn: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class Contains(PatternLookup):
bilateral_transforms: List[Type[lookups.Transform]]
contains_aggregate: bool
lhs: Expression
rhs: Union[Expression, str]
lookup_name: str = ...
class IContains(Contains):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: Union[Expression, str]
lookup_name: str = ...
class StartsWith(PatternLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: Union[Expression, str]
lookup_name: str = ...
param_pattern: str = ...
class IStartsWith(StartsWith):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: Union[Expression, str]
lookup_name: str = ...
class EndsWith(PatternLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: Union[Expression, str]
lookup_name: str = ...
param_pattern: str = ...
class IEndsWith(EndsWith):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: Union[Expression, str]
lookup_name: str = ...
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
bilateral_transforms: List[Type[lookups.Transform]]
contains_aggregate: bool
lhs: Expression
rhs: Union[
List[datetime.datetime],
Tuple[
Union[expressions.F, int],
Union[datetime.datetime, int],
],
]
lookup_name: str = ...
def get_rhs_op(
self, connection: DatabaseWrapper, rhs: Tuple[str, str]
) -> str: ...
class IsNull(BuiltinLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: Expression
rhs: bool
lookup_name: str = ...
prepare_rhs: bool = ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
class Regex(BuiltinLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: str
lookup_name: str = ...
prepare_rhs: bool = ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
class IRegex(Regex):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: expressions.Col
rhs: str
lookup_name: str = ...
class YearLookup(Lookup):
def year_lookup_bounds(
self, connection: DatabaseWrapper, year: int
) -> List[str]: ...
class YearComparisonLookup(YearLookup):
bilateral_transforms: List[Any]
lhs: expressions.Value
rhs: expressions.Value
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
def get_bound(self, start: datetime, finish: datetime) -> Any: ...
class YearExact(YearLookup, Exact):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: django.db.models.functions.datetime.ExtractYear
rhs: Union[django.db.models.functions.datetime.Extract, int, str]
lookup_name: str = ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[str]]: ...
class YearGt(YearComparisonLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: django.db.models.functions.datetime.ExtractYear
rhs: int
lookup_name: str = ...
def get_bound(self, start: str, finish: str) -> str: ...
class YearGte(YearComparisonLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: django.db.models.functions.datetime.ExtractYear
rhs: int
lookup_name: str = ...
def get_bound(self, start: str, finish: str) -> str: ...
class YearLt(YearComparisonLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: django.db.models.functions.datetime.ExtractYear
rhs: int
lookup_name: str = ...
def get_bound(self, start: str, finish: str) -> str: ...
class YearLte(YearComparisonLookup):
bilateral_transforms: List[Any]
contains_aggregate: bool
lhs: django.db.models.functions.datetime.ExtractYear
rhs: int
lookup_name: str = ...
def get_bound(self, start: str, finish: str) -> str: ...

View File

@@ -0,0 +1,154 @@
from collections import OrderedDict
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Optional, Tuple, Type, Union, TypeVar, Set, Generic
from unittest.mock import MagicMock
from django.contrib.sites.managers import CurrentSiteManager
from django.db.models import Q
from django.db.models.base import Model
from django.db.models.query import QuerySet, RawQuerySet
_T = TypeVar('_T', bound=Model)
class BaseManager:
creation_counter: int = ...
auto_created: bool = ...
use_in_migrations: bool = ...
def __new__(cls: Type[Manager], *args: Any, **kwargs: Any) -> Manager: ...
model: Any = ...
name: Any = ...
def __init__(self) -> None: ...
def deconstruct(self) -> Tuple[bool, str, None, Tuple, Dict[str, int]]: ...
def check(self, **kwargs: Any) -> List[Any]: ...
@classmethod
def from_queryset(
cls, queryset_class: Any, class_name: Optional[Any] = ...
): ...
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
def db_manager(
self,
using: Optional[str] = ...,
hints: Optional[Dict[str, Model]] = ...,
) -> Manager: ...
@property
def db(self) -> str: ...
def get_queryset(self) -> QuerySet: ...
def all(self) -> QuerySet: ...
def __eq__(self, other: Optional[CurrentSiteManager]) -> bool: ...
def __hash__(self): ...
class Manager(Generic[_T]):
def exists(self) -> bool: ...
def explain(
self, *, format: Optional[Any] = ..., **options: Any
) -> str: ...
def raw(
self,
raw_query: str,
params: Optional[
Union[
Dict[str, str],
List[datetime],
List[Decimal],
List[str],
Set[str],
Tuple[int],
]
] = ...,
translations: Optional[Dict[str, str]] = ...,
using: None = ...,
) -> RawQuerySet: ...
def values(self, *fields: Any, **expressions: Any) -> QuerySet: ...
def values_list(
self, *fields: Any, flat: bool = ..., named: bool = ...
) -> QuerySet: ...
def dates(
self, field_name: str, kind: str, order: str = ...
) -> QuerySet: ...
def datetimes(
self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...
) -> QuerySet: ...
def none(self) -> QuerySet[_T]: ...
def all(self) -> QuerySet[_T]: ...
def filter(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def exclude(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def complex_filter(
self,
filter_obj: Union[
Dict[str, datetime], Dict[str, QuerySet], Q, MagicMock
],
) -> QuerySet[_T]: ...
def union(self, *other_qs: Any, all: bool = ...) -> QuerySet[_T]: ...
def intersection(self, *other_qs: Any) -> QuerySet[_T]: ...
def difference(self, *other_qs: Any) -> QuerySet[_T]: ...
def select_for_update(
self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...
) -> QuerySet: ...
def select_related(self, *fields: Any) -> QuerySet[_T]: ...
def prefetch_related(self, *lookups: Any) -> QuerySet[_T]: ...
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def order_by(self, *field_names: Any) -> QuerySet[_T]: ...
def distinct(self, *field_names: Any) -> QuerySet[_T]: ...
def extra(
self,
select: Optional[
Union[Dict[str, int], Dict[str, str], OrderedDict]
] = ...,
where: Optional[List[str]] = ...,
params: Optional[Union[List[int], List[str]]] = ...,
tables: Optional[List[str]] = ...,
order_by: Optional[Union[List[str], Tuple[str]]] = ...,
select_params: Optional[Union[List[int], List[str], Tuple[int]]] = ...,
) -> QuerySet[_T]: ...
def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
def aggregate(
self, *args: Any, **kwargs: Any
) -> Dict[str, Optional[Union[datetime, float]]]: ...
def count(self) -> int: ...
def get(
self, *args: Any, **kwargs: Any
) -> _T: ...
def create(self, **kwargs: Any) -> _T: ...
class ManagerDescriptor:
manager: Manager = ...
def __init__(self, manager: Manager) -> None: ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> Manager: ...
class EmptyManager(Manager):
creation_counter: int
name: None
model: Optional[Type[Model]] = ...
def __init__(self, model: Type[Model]) -> None: ...
def get_queryset(self) -> QuerySet: ...

View File

@@ -0,0 +1,161 @@
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union)
from django.apps.config import AppConfig
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AbstractUser, PermissionsMixin
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.postgres.fields.array import ArrayField
from django.contrib.postgres.fields.citext import CIText
from django.contrib.sessions.base_session import AbstractBaseSession
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import OneToOneField
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.manager import Manager
from django.db.models.query_utils import PathInfo
from django.utils.datastructures import ImmutableList
PROXY_PARENTS: Any
EMPTY_RELATION_TREE: Any
IMMUTABLE_WARNING: str
DEFAULT_NAMES: Any
def normalize_together(
option_together: Any
) -> Union[
List[Union[Tuple[str, str], int]], Set[Tuple[str, str]], Tuple, int, str
]: ...
def make_immutable_fields_list(
name: str,
data: Union[
Iterator[Any],
List[Union[ArrayField, CIText]],
List[Union[Field, FieldCacheMixin]],
],
) -> ImmutableList: ...
class Options:
base_manager: django.db.models.manager.Manager
concrete_fields: django.utils.datastructures.ImmutableList
default_manager: django.db.models.manager.Manager
fields: django.utils.datastructures.ImmutableList
local_concrete_fields: django.utils.datastructures.ImmutableList
managers: django.utils.datastructures.ImmutableList
managers_map: Dict[str, django.db.models.manager.Manager]
related_objects: django.utils.datastructures.ImmutableList
FORWARD_PROPERTIES: Any = ...
REVERSE_PROPERTIES: Any = ...
default_apps: Any = ...
local_fields: List[django.db.models.fields.Field] = ...
local_many_to_many: List[
django.db.models.fields.related.ManyToManyField
] = ...
private_fields: List[Any] = ...
local_managers: List[django.db.models.manager.Manager] = ...
base_manager_name: None = ...
default_manager_name: None = ...
model_name: Optional[str] = ...
verbose_name: Optional[str] = ...
verbose_name_plural: Optional[str] = ...
db_table: str = ...
ordering: List[str] = ...
indexes: List[Any] = ...
unique_together: Union[List[Any], Tuple] = ...
index_together: Union[List[Any], Tuple] = ...
select_on_save: bool = ...
default_permissions: Tuple[str, str, str, str] = ...
permissions: List[Any] = ...
object_name: Optional[str] = ...
app_label: str = ...
get_latest_by: None = ...
order_with_respect_to: None = ...
db_tablespace: str = ...
required_db_features: List[Any] = ...
required_db_vendor: None = ...
meta: Optional[
Type[
Union[
django.contrib.auth.base_user.AbstractBaseUser.Meta,
django.contrib.auth.models.AbstractUser.Meta,
django.contrib.auth.models.PermissionsMixin.Meta,
django.contrib.sessions.base_session.AbstractBaseSession.Meta,
]
]
] = ...
pk: Optional[django.db.models.fields.Field] = ...
auto_field: Optional[django.db.models.fields.AutoField] = ...
abstract: bool = ...
managed: bool = ...
proxy: bool = ...
proxy_for_model: None = ...
concrete_model: Optional[Type[django.db.models.base.Model]] = ...
swappable: None = ...
parents: collections.OrderedDict = ...
auto_created: bool = ...
related_fkey_lookups: List[Any] = ...
apps: django.apps.registry.Apps = ...
default_related_name: None = ...
def __init__(
self,
meta: Optional[
Type[
Union[
AbstractBaseUser.Meta,
AbstractUser.Meta,
PermissionsMixin.Meta,
AbstractBaseSession.Meta,
]
]
],
app_label: Optional[str] = ...,
) -> None: ...
@property
def label(self) -> str: ...
@property
def label_lower(self) -> str: ...
@property
def app_config(self) -> AppConfig: ...
@property
def installed(self): ...
model: Type[django.db.models.base.Model] = ...
original_attrs: Dict[
str, Union[List[str], django.apps.registry.Apps, str]
] = ...
def contribute_to_class(self, cls: Type[Model], name: str) -> None: ...
def add_manager(self, manager: Manager) -> None: ...
def add_field(
self, field: Union[GenericForeignKey, Field], private: bool = ...
) -> None: ...
def setup_pk(self, field: Field) -> None: ...
def setup_proxy(self, target: Type[Model]) -> None: ...
def can_migrate(self, connection: Union[DatabaseWrapper, str]) -> bool: ...
@property
def verbose_name_raw(self) -> Any: ...
@property
def swapped(self) -> Optional[str]: ...
def managers(self) -> ImmutableList: ...
def managers_map(self) -> Dict[str, Manager]: ...
def base_manager(self) -> Manager: ...
def default_manager(self) -> Manager: ...
def fields(self) -> ImmutableList: ...
def concrete_fields(self) -> ImmutableList: ...
def local_concrete_fields(self) -> ImmutableList: ...
def many_to_many(self) -> ImmutableList: ...
def related_objects(self) -> ImmutableList: ...
def fields_map(self) -> Dict[str, ForeignObjectRel]: ...
def get_field(
self, field_name: Union[Callable, str]
) -> Union[Field, mixins.FieldCacheMixin]: ...
def get_base_chain(self, model: Type[Model]) -> List[Type[Model]]: ...
def get_parent_list(self) -> List[Type[Model]]: ...
def get_ancestor_link(
self, ancestor: Type[Model]
) -> Optional[OneToOneField]: ...
def get_path_to_parent(self, parent: Type[Model]) -> List[PathInfo]: ...
def get_path_from_parent(self, parent: Type[Model]) -> List[PathInfo]: ...
def get_fields(
self, include_parents: bool = ..., include_hidden: bool = ...
) -> ImmutableList: ...

View File

@@ -0,0 +1,450 @@
import decimal
import operator
from collections import OrderedDict
from datetime import date, datetime
from decimal import Decimal
from itertools import chain
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union, Generic, TypeVar, overload)
from unittest.mock import MagicMock
from uuid import UUID
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models
from django.db.models.base import Model, ModelState
from django.db.models.expressions import Expression
from django.db.models.fields import Field
from django.db.models.fields.related_descriptors import (ForwardManyToOneDescriptor,
ReverseOneToOneDescriptor)
from django.db.models.query_utils import Q
from django.db.models.sql.query import Query, RawQuery
REPR_OUTPUT_SIZE: int
EmptyResultSet: Any
class BaseIterable:
queryset: Any = ...
chunked_fetch: Any = ...
chunk_size: Any = ...
def __init__(
self,
queryset: QuerySet,
chunked_fetch: bool = ...,
chunk_size: int = ...,
) -> None: ...
class ModelIterable(BaseIterable):
chunk_size: int
chunked_fetch: bool
queryset: QuerySet
def __iter__(self) -> Iterator[Model]: ...
class ValuesIterable(BaseIterable):
chunk_size: int
chunked_fetch: bool
queryset: QuerySet
def __iter__(self) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ...
class ValuesListIterable(BaseIterable):
chunk_size: int
chunked_fetch: bool
queryset: QuerySet
def __iter__(self) -> Union[chain, map]: ...
class NamedValuesListIterable(ValuesListIterable):
chunk_size: int
chunked_fetch: bool
queryset: QuerySet
@staticmethod
def create_namedtuple_class(*names: Any) -> Any: ...
def __iter__(self) -> Any: ...
class FlatValuesListIterable(BaseIterable):
chunk_size: int
chunked_fetch: bool
queryset: QuerySet
def __iter__(self) -> Iterator[Any]: ...
_T = TypeVar('_T', bound=models.Model)
class QuerySet(Generic[_T]):
model: Optional[Type[models.Model]] = ...
query: models.sql.Query = ...
def __init__(
self,
model: Optional[Type[Model]] = ...,
query: Optional[Query] = ...,
using: Optional[str] = ...,
hints: Optional[Dict[str, Model]] = ...,
) -> None: ...
def as_manager(cls): ...
def __deepcopy__(
self,
memo: Dict[
int,
Union[
Dict[str, Union[ModelState, int, str]],
List[Union[Dict[str, Union[bool, str]], ModelState]],
Model,
ModelState,
],
],
) -> QuerySet[_T]: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __bool__(self) -> bool: ...
@overload
def __getitem__(self, k: slice) -> QuerySet[_T]: ...
@overload
def __getitem__(self, k: int) -> _T: ...
@overload
def __getitem__(self, k: str) -> Any: ...
def __and__(self, other: QuerySet) -> QuerySet: ...
def __or__(self, other: QuerySet) -> QuerySet: ...
def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
def aggregate(
self, *args: Any, **kwargs: Any
) -> Dict[str, Optional[Union[datetime, float]]]: ...
def count(self) -> int: ...
def get(
self, *args: Any, **kwargs: Any
) -> _T: ...
def create(self, **kwargs: Any) -> _T: ...
def bulk_create(
self,
objs: Union[Iterator[Any], List[Model]],
batch_size: Optional[int] = ...,
) -> List[_T]: ...
def get_or_create(
self,
defaults: Optional[Union[Dict[str, date], Dict[str, Model]]] = ...,
**kwargs: Any
) -> Tuple[_T, bool]: ...
def update_or_create(
self,
defaults: Optional[
Union[
Dict[str, Callable],
Dict[str, date],
Dict[str, Model],
Dict[str, str],
]
] = ...,
**kwargs: Any
) -> Tuple[_T, bool]: ...
def earliest(
self, *fields: Any, field_name: Optional[Any] = ...
) -> _T: ...
def latest(
self, *fields: Any, field_name: Optional[Any] = ...
) -> _T: ...
def first(self) -> Optional[Union[Dict[str, int], _T]]: ...
def last(self) -> Optional[_T]: ...
def in_bulk(
self, id_list: Any = ..., *, field_name: str = ...
) -> Union[Dict[int, Model], Dict[str, Model]]: ...
def delete(self) -> Tuple[int, Dict[str, int]]: ...
def update(self, **kwargs: Any) -> int: ...
def exists(self) -> bool: ...
def explain(
self, *, format: Optional[Any] = ..., **options: Any
) -> str: ...
def raw(
self,
raw_query: str,
params: Optional[
Union[
Dict[str, str],
List[datetime],
List[Decimal],
List[str],
Set[str],
Tuple[int],
]
] = ...,
translations: Optional[Dict[str, str]] = ...,
using: None = ...,
) -> RawQuerySet: ...
def values(self, *fields: Any, **expressions: Any) -> QuerySet: ...
def values_list(
self, *fields: Any, flat: bool = ..., named: bool = ...
) -> QuerySet: ...
def dates(
self, field_name: str, kind: str, order: str = ...
) -> QuerySet: ...
def datetimes(
self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...
) -> QuerySet: ...
def none(self) -> QuerySet[_T]: ...
def all(self) -> QuerySet[_T]: ...
def filter(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def exclude(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def complex_filter(
self,
filter_obj: Union[
Dict[str, datetime], Dict[str, QuerySet], Q, MagicMock
],
) -> QuerySet[_T]: ...
def union(self, *other_qs: Any, all: bool = ...) -> QuerySet[_T]: ...
def intersection(self, *other_qs: Any) -> QuerySet[_T]: ...
def difference(self, *other_qs: Any) -> QuerySet[_T]: ...
def select_for_update(
self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...
) -> QuerySet: ...
def select_related(self, *fields: Any) -> QuerySet[_T]: ...
def prefetch_related(self, *lookups: Any) -> QuerySet[_T]: ...
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def order_by(self, *field_names: Any) -> QuerySet[_T]: ...
def distinct(self, *field_names: Any) -> QuerySet[_T]: ...
def extra(
self,
select: Optional[
Union[Dict[str, int], Dict[str, str], OrderedDict]
] = ...,
where: Optional[List[str]] = ...,
params: Optional[Union[List[int], List[str]]] = ...,
tables: Optional[List[str]] = ...,
order_by: Optional[Union[List[str], Tuple[str]]] = ...,
select_params: Optional[Union[List[int], List[str], Tuple[int]]] = ...,
) -> QuerySet[_T]: ...
def reverse(self) -> QuerySet[_T]: ...
def defer(self, *fields: Any) -> QuerySet[_T]: ...
def only(self, *fields: Any) -> QuerySet[_T]: ...
def using(self, alias: Optional[str]) -> QuerySet[_T]: ...
@property
def ordered(self) -> bool: ...
@property
def db(self) -> str: ...
def resolve_expression(self, *args: Any, **kwargs: Any) -> Query: ...
class InstanceCheckMeta(type):
def __instancecheck__(self, instance: Union[QuerySet, str]) -> bool: ...
class EmptyQuerySet:
def __init__(self, *args: Any, **kwargs: Any) -> Any: ...
class RawQuerySet:
columns: List[str]
model_fields: Dict[str, models.Field]
raw_query: str = ...
model: Optional[Type[models.Model]] = ...
query: models.sql.RawQuery = ...
params: Union[
Dict[str, str],
List[datetime],
List[decimal.Decimal],
List[str],
Set[str],
Tuple,
] = ...
translations: Dict[str, str] = ...
def __init__(
self,
raw_query: str,
model: Optional[Type[Model]] = ...,
query: Optional[RawQuery] = ...,
params: Optional[
Union[
Dict[str, str],
List[datetime],
List[Decimal],
List[str],
Set[str],
Tuple,
]
] = ...,
translations: Optional[Dict[str, str]] = ...,
using: Optional[str] = ...,
hints: Optional[Dict[Any, Any]] = ...,
) -> None: ...
def resolve_model_init_order(
self
) -> Tuple[List[str], List[int], List[Tuple[str, int]]]: ...
def prefetch_related(self, *lookups: Any) -> RawQuerySet: ...
def __len__(self) -> int: ...
def __bool__(self) -> bool: ...
def __iter__(self) -> Any: ...
def iterator(self) -> Iterator[Model]: ...
def __getitem__(
self, k: Union[int, slice, str]
) -> Union[List[Model], Model]: ...
@property
def db(self) -> str: ...
def using(self, alias: Any): ...
def columns(self) -> List[str]: ...
def model_fields(self) -> Dict[str, Field]: ...
class Prefetch:
prefetch_through: str = ...
prefetch_to: str = ...
queryset: Optional[QuerySet] = ...
to_attr: Optional[str] = ...
def __init__(
self,
lookup: str,
queryset: Optional[QuerySet] = ...,
to_attr: Optional[str] = ...,
) -> None: ...
def add_prefix(self, prefix: str) -> None: ...
def get_current_prefetch_to(self, level: int) -> str: ...
def get_current_to_attr(self, level: int) -> Tuple[str, Optional[bool]]: ...
def get_current_queryset(self, level: int) -> Optional[QuerySet]: ...
def __eq__(self, other: None) -> bool: ...
def __hash__(self) -> int: ...
def normalize_prefetch_lookups(
lookups: reversed, prefix: None = ...
) -> List[Prefetch]: ...
def prefetch_related_objects(
model_instances: Union[List[Model], List[UUID]], *related_lookups: Any
) -> None: ...
def get_prefetcher(
instance: Model, through_attr: str, to_attr: str
) -> Tuple[
GenericForeignKey, Union[GenericForeignKey, property], bool, bool
]: ...
def prefetch_one_level(
instances: List[Model],
prefetcher: Union[
GenericForeignKey, ForwardManyToOneDescriptor, ReverseOneToOneDescriptor
],
lookup: Prefetch,
level: int,
) -> Tuple[List[Model], List[Prefetch]]: ...
class RelatedPopulator:
db: str = ...
cols_start: int = ...
cols_end: int = ...
init_list: List[str] = ...
reorder_for_init: Optional[operator.itemgetter] = ...
model_cls: Type[models.Model] = ...
pk_idx: int = ...
related_populators: List[models.query.RelatedPopulator] = ...
local_setter: Callable = ...
remote_setter: Callable = ...
def __init__(
self,
klass_info: Dict[str, Any],
select: List[Tuple[Expression, Tuple[str, List[int]], Optional[str]]],
db: str,
) -> None: ...
def populate(
self,
row: Union[
List[Optional[Union[date, int, str]]],
List[Union[date, Decimal, float, str]],
Tuple[Union[int, str], str, int],
],
from_obj: Model,
) -> None: ...
def get_related_populators(
klass_info: Dict[str, Any],
select: List[Tuple[Expression, Tuple[str, List[bool]], Optional[str]]],
db: str,
) -> List[RelatedPopulator]: ...

View File

@@ -0,0 +1,148 @@
from collections import OrderedDict, namedtuple
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
from django.db.backends.sqlite3.base import DatabaseWrapper
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.fields.mixins import FieldCacheMixin
from django.db.models.functions.datetime import TimezoneMixin
from django.db.models.lookups import (FieldGetDbPrepValueMixin,
IntegerFieldFloatRounding, 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
from django.db.models.sql.where import WhereNode
from django.utils import tree
PathInfo = namedtuple(
"PathInfo",
"from_opts to_opts target_fields join_field m2m direct filtered_relation",
)
class InvalidQuery(Exception): ...
def subclasses(
cls: Type[RegisterLookupMixin]
) -> Iterator[Type[RegisterLookupMixin]]: ...
class QueryWrapper:
contains_aggregate: bool = ...
data: Tuple[str, List[Any]] = ...
def __init__(self, sql: str, params: List[Any]) -> None: ...
def as_sql(
self, compiler: SQLCompiler = ..., connection: DatabaseWrapper = ...
) -> Tuple[str, List[Any]]: ...
class Q(tree.Node):
children: Union[
List[Dict[str, str]],
List[Tuple[str, Any]],
List[django.db.models.query_utils.Q],
]
connector: str
negated: bool
AND: str = ...
OR: str = ...
default: Any = ...
conditional: bool = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def __or__(self, other: Any) -> Q: ...
def __and__(self, other: Any) -> Q: ...
def __invert__(self) -> Q: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> WhereNode: ...
def deconstruct(self) -> Tuple[str, Tuple, Dict[str, str]]: ...
class DeferredAttribute:
field_name: str = ...
def __init__(self, field_name: str) -> None: ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> Any: ...
class RegisterLookupMixin:
@classmethod
def get_lookups(
cls
) -> Dict[str, Type[Union[TimezoneMixin, Lookup, Transform]]]: ...
def get_lookup(
self, lookup_name: str
) -> Optional[Type[Union[FieldGetDbPrepValueMixin, Lookup]]]: ...
def get_transform(self, lookup_name: str) -> Optional[Type[Transform]]: ...
@staticmethod
def merge_dicts(
dicts: List[
Dict[
str,
Type[
Union[
TimezoneMixin,
FieldGetDbPrepValueMixin,
IntegerFieldFloatRounding,
Lookup,
Transform,
]
],
]
]
) -> Dict[
str,
Type[Union[TimezoneMixin, FieldGetDbPrepValueMixin, Lookup, Transform]],
]: ...
@classmethod
def register_lookup(
cls,
lookup: Type[Union[Lookup, Transform]],
lookup_name: Optional[str] = ...,
) -> Type[Union[Lookup, Transform]]: ...
def select_related_descend(
field: Field,
restricted: bool,
requested: Optional[
Union[
Dict[
str,
Dict[
str,
Dict[
str,
Dict[
str, Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]]
],
],
],
],
bool,
]
],
load_fields: Optional[Set[str]],
reverse: bool = ...,
) -> bool: ...
def refs_expression(
lookup_parts: List[str], annotations: OrderedDict
) -> Union[Tuple[bool, Tuple], Tuple[Expression, List[str]]]: ...
def check_rel_lookup_compatibility(
model: Type[Model], target_opts: Options, field: FieldCacheMixin
) -> bool: ...
class FilteredRelation:
relation_name: str = ...
alias: Optional[str] = ...
condition: django.db.models.query_utils.Q = ...
path: List[str] = ...
def __init__(self, relation_name: str, *, condition: Any = ...) -> None: ...
def __eq__(self, other: FilteredRelation) -> bool: ...
def clone(self) -> FilteredRelation: ...
def resolve_expression(self, *args: Any, **kwargs: Any) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Union[int, str]]]: ...

View File

@@ -0,0 +1,34 @@
from typing import Any, Callable, Optional, Type, Union
from django.apps.registry import Apps
from django.db.models.base import Model
from django.dispatch import Signal
class_prepared: Any
class ModelSignal(Signal):
def connect(
self,
receiver: Callable,
sender: Optional[Union[Type[Model], str]] = ...,
weak: bool = ...,
dispatch_uid: None = ...,
apps: Optional[Apps] = ...,
) -> None: ...
def disconnect(
self,
receiver: Callable = ...,
sender: Optional[Union[Type[Model], str]] = ...,
dispatch_uid: None = ...,
apps: Optional[Apps] = ...,
) -> Optional[bool]: ...
pre_init: Any
post_init: Any
pre_save: Any
post_save: Any
pre_delete: Any
post_delete: Any
m2m_changed: Any
pre_migrate: Any
post_migrate: Any

View File

@@ -0,0 +1,254 @@
from datetime import date, datetime
from decimal import Decimal
from itertools import chain
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union)
from uuid import UUID
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 (BaseExpression, Col, Expression,
OrderBy, RawSQL, SQLiteNumericMixin)
from django.db.models.fields import DateTimeCheckMixin, Field
from django.db.models.functions.text import Lower
from django.db.models.options import Options
from django.db.models.sql.query import Query, RawQuery
from django.utils.datastructures import ImmutableList
FORCE: Any
class SQLCompiler:
query: Any = ...
connection: Any = ...
using: Any = ...
quote_cache: Any = ...
select: Any = ...
annotation_col_map: Any = ...
klass_info: Any = ...
ordering_parts: Any = ...
def __init__(
self,
query: Union[Query, RawQuery],
connection: DatabaseWrapper,
using: Optional[str],
) -> None: ...
col_count: Any = ...
def setup_query(self) -> None: ...
has_extra_select: Any = ...
def pre_sql_setup(
self
) -> Tuple[
List[
Tuple[OrderBy, Tuple[str, Union[List[Any], Tuple[str, str]]], None]
],
List[Tuple[OrderBy, Tuple[str, List[Union[int, str]], bool]]],
List[Tuple[str, List[float]]],
]: ...
def get_group_by(
self,
select: List[
Tuple[
Union[BaseExpression, SQLiteNumericMixin],
Tuple[str, List[float]],
Optional[str],
]
],
order_by: List[Tuple[OrderBy, Tuple[str, List[Union[int, str]], bool]]],
) -> List[Tuple[str, List[float]]]: ...
def collapse_group_by(
self,
expressions: List[Expression],
having: Union[List[Expression], Tuple],
) -> List[Expression]: ...
def get_select(
self
) -> Tuple[
List[
Tuple[
Union[Expression, SQLiteNumericMixin],
Tuple[str, List[Union[int, str]]],
Optional[str],
]
],
Optional[
Dict[str, Any]
],
Dict[str, int],
]: ...
def get_order_by(
self
) -> List[Tuple[OrderBy, Tuple[str, List[Any], bool]]]: ...
def get_extra_select(
self,
order_by: List[Tuple[OrderBy, Tuple[str, List[Any], bool]]],
select: List[
Tuple[
Union[Expression, SQLiteNumericMixin],
Tuple[str, List[float]],
Optional[str],
]
],
) -> List[Tuple[OrderBy, Tuple[str, List[Any]], None]]: ...
def quote_name_unless_alias(self, name: str) -> str: ...
def compile(
self, node: Any, select_format: Any = ...
) -> Tuple[str, Union[List[Optional[int]], Tuple[int, int]]]: ...
def get_combinator_sql(
self, combinator: str, all: bool
) -> Tuple[List[str], Union[List[int], List[str]]]: ...
def as_sql(
self, with_limits: bool = ..., with_col_aliases: bool = ...
) -> Any: ...
def get_default_columns(
self,
start_alias: Optional[str] = ...,
opts: Optional[Options] = ...,
from_parent: Optional[Type[Model]] = ...,
) -> List[Col]: ...
def get_distinct(self) -> Tuple[List[Any], List[Any]]: ...
def find_ordering_name(
self,
name: str,
opts: Options,
alias: Optional[str] = ...,
default_order: str = ...,
already_seen: Optional[
Set[Tuple[Optional[Tuple[Tuple[str, str]]], Tuple[Tuple[str, str]]]]
] = ...,
) -> List[Tuple[OrderBy, bool]]: ...
def get_from_clause(self) -> Tuple[List[str], List[Union[int, str]]]: ...
def get_related_selections(
self,
select: List[Tuple[Expression, Optional[str]]],
opts: Optional[Options] = ...,
root_alias: Optional[str] = ...,
cur_depth: int = ...,
requested: Optional[
Union[Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]], bool]
] = ...,
restricted: Optional[bool] = ...,
) -> List[Dict[str, Any]]: ...
def get_select_for_update_of_arguments(self): ...
def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ...
def get_converters(
self, expressions: Union[List[RawSQL], List[SQLiteNumericMixin]]
) -> Dict[
int, Tuple[List[Callable], Union[Expression, SQLiteNumericMixin]]
]: ...
def apply_converters(
self,
rows: chain,
converters: Dict[
int, Tuple[List[Callable], Union[Expression, SQLiteNumericMixin]]
],
) -> Iterator[
Union[
List[Optional[Union[bytes, datetime, int, str]]],
List[Optional[Union[date, Decimal, float, str]]],
List[Optional[Union[datetime, float, str, UUID]]],
]
]: ...
def results_iter(
self,
results: Optional[
Union[Iterator[Any], List[List[Tuple[Union[int, str]]]]]
] = ...,
tuple_expected: bool = ...,
chunked_fetch: bool = ...,
chunk_size: int = ...,
) -> Union[Iterator[Any], chain, map]: ...
def has_results(self) -> bool: ...
def execute_sql(
self,
result_type: str = ...,
chunked_fetch: bool = ...,
chunk_size: int = ...,
) -> Optional[Union[Iterator[Any], CursorWrapper]]: ...
def as_subquery_condition(
self, alias: str, columns: List[str], compiler: SQLCompiler
) -> Tuple[str, Tuple]: ...
def explain_query(self) -> Iterator[str]: ...
class SQLInsertCompiler(SQLCompiler):
return_id: bool = ...
def field_as_sql(
self, field: Optional[Field], val: Optional[Union[Lower, float, str]]
) -> Tuple[str, Union[List[int], List[str]]]: ...
def prepare_value(
self, field: Field, value: Any
) -> Optional[Union[Lower, float, str]]: ...
def pre_save_val(self, field: Field, obj: Model) -> Any: ...
def assemble_as_sql(
self,
fields: Union[
List[None], List[DateTimeCheckMixin], List[Field], ImmutableList
],
value_rows: Union[
List[List[Optional[Union[Lower, int]]]], List[List[Union[int, str]]]
],
) -> Tuple[Tuple[Tuple[str]], List[List[Optional[Union[int, str]]]]]: ...
def as_sql(self) -> List[Tuple[str, Tuple[Union[float, str]]]]: ...
def execute_sql(self, return_id: Optional[bool] = ...) -> Any: ...
class SQLDeleteCompiler(SQLCompiler):
def as_sql(self) -> Tuple[str, Tuple]: ...
class SQLUpdateCompiler(SQLCompiler):
def as_sql(self) -> Tuple[str, Tuple]: ...
def execute_sql(self, result_type: str) -> int: ...
def pre_sql_setup(self) -> None: ...
class SQLAggregateCompiler(SQLCompiler):
col_count: Any = ...
def as_sql(self) -> Tuple[str, Tuple]: ...
def cursor_iter(
cursor: CursorWrapper,
sentinel: List[Any],
col_count: Optional[int],
itersize: int,
) -> Iterator[List[Tuple[Union[date, int]]]]: ...

View File

@@ -0,0 +1,66 @@
from collections import OrderedDict
from typing import Any, Dict, List, Optional, Tuple, Union
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.query_utils import FilteredRelation, PathInfo
from django.db.models.sql.compiler import SQLCompiler
class MultiJoin(Exception):
level: int = ...
names_with_path: List[
Tuple[str, List[django.db.models.query_utils.PathInfo]]
] = ...
def __init__(
self, names_pos: int, path_with_names: List[Tuple[str, List[PathInfo]]]
) -> None: ...
class Empty: ...
class Join:
table_name: str = ...
parent_alias: str = ...
table_alias: Optional[str] = ...
join_type: str = ...
join_cols: Tuple = ...
join_field: django.db.models.fields.mixins.FieldCacheMixin = ...
nullable: bool = ...
filtered_relation: Optional[
django.db.models.query_utils.FilteredRelation
] = ...
def __init__(
self,
table_name: str,
parent_alias: str,
table_alias: Optional[str],
join_type: str,
join_field: FieldCacheMixin,
nullable: bool,
filtered_relation: Optional[FilteredRelation] = ...,
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Union[int, str]]]: ...
def relabeled_clone(
self, change_map: Union[Dict[str, str], OrderedDict]
) -> Join: ...
def equals(
self, other: Union[BaseTable, Join], with_filtered_relation: bool
) -> bool: ...
def __eq__(self, other: Union[BaseTable, Join]) -> bool: ...
def demote(self) -> Join: ...
def promote(self) -> Join: ...
class BaseTable:
join_type: Any = ...
parent_alias: Any = ...
filtered_relation: Any = ...
table_name: str = ...
table_alias: Optional[str] = ...
def __init__(self, table_name: str, alias: Optional[str]) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, List[Any]]: ...
def relabeled_clone(self, change_map: OrderedDict) -> BaseTable: ...
def equals(self, other: Join, with_filtered_relation: bool) -> bool: ...

View File

@@ -0,0 +1,384 @@
from collections import OrderedDict, namedtuple
from datetime import datetime
from decimal import Decimal
from typing import (Any, Callable, Dict, Iterator, List, Optional, Set, Tuple,
Type, Union)
from uuid import UUID
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model, ModelState
from django.db.models.expressions import (Combinable, Expression,
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,
ManyToOneRel)
from django.db.models.lookups import (FieldGetDbPrepValueMixin,
IntegerLessThan, Lookup, Transform)
from django.db.models.options import Options
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.where import WhereNode
JoinInfo = namedtuple(
"JoinInfo",
["final_field", "targets", "opts", "joins", "path", "transform_function"],
)
class RawQuery:
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: str,
using: str,
params: Optional[
Union[
Dict[str, str],
List[datetime],
List[Decimal],
List[str],
Set[str],
Tuple[int],
]
] = ...,
) -> None: ...
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) -> Type[Union[dict, tuple]]: ...
class Query:
base_table: str
related_ids: None
related_updates: Dict[
Type[django.db.models.base.Model],
List[Tuple[django.db.models.fields.Field, None, Union[int, str]]],
]
values: List[
Tuple[
django.db.models.fields.Field,
Optional[Type[django.db.models.base.Model]],
django.db.models.aggregates.Max,
]
]
alias_prefix: str = ...
subq_aliases: frozenset = ...
compiler: str = ...
model: Optional[Type[django.db.models.base.Model]] = ...
alias_refcount: Dict[str, int] = ...
alias_map: collections.OrderedDict = ...
external_aliases: Set[str] = ...
table_map: Dict[str, List[str]] = ...
default_cols: bool = ...
default_ordering: bool = ...
standard_ordering: bool = ...
used_aliases: Set[str] = ...
filter_is_sticky: bool = ...
subquery: bool = ...
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[Union[Tuple, bool]] = ...
order_by: Tuple = ...
distinct: bool = ...
distinct_fields: Tuple = ...
select_for_update: bool = ...
select_for_update_nowait: bool = ...
select_for_update_skip_locked: bool = ...
select_for_update_of: Tuple = ...
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: Optional[str] = ...
combinator_all: bool = ...
combined_queries: Tuple = ...
extra_select_mask: Optional[Set[str]] = ...
extra_tables: Tuple = ...
extra_order_by: Union[List[str], Tuple] = ...
deferred_loading: Tuple[Union[Set[str], frozenset], bool] = ...
explain_query: bool = ...
explain_format: Optional[str] = ...
explain_options: Dict[str, int] = ...
def __init__(
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) -> bool: ...
def base_table(self) -> str: ...
def sql_with_params(self) -> Tuple[str, Tuple]: ...
def __deepcopy__(
self,
memo: Dict[
int,
Union[
Dict[str, Union[ModelState, int, str]],
List[Union[Dict[str, Union[bool, str]], ModelState]],
Model,
ModelState,
],
],
) -> Query: ...
def get_compiler(
self,
using: Optional[str] = ...,
connection: Optional[DatabaseWrapper] = ...,
) -> SQLCompiler: ...
def get_meta(self) -> Options: ...
def clone(self) -> Query: ...
def chain(self, klass: Optional[Type[Query]] = ...) -> Query: ...
def relabeled_clone(
self, change_map: Union[Dict[Any, Any], OrderedDict]
) -> Query: ...
def rewrite_cols(
self,
annotation: Union[Expression, FieldGetDbPrepValueMixin, WhereNode],
col_cnt: int,
) -> Tuple[Union[Expression, IntegerLessThan], int]: ...
def get_aggregation(
self,
using: str,
added_aggregate_names: Union[Dict[str, SQLiteNumericMixin], List[str]],
) -> Dict[str, Optional[Union[datetime, Decimal, float]]]: ...
def get_count(self, using: str) -> int: ...
def has_filters(self) -> WhereNode: ...
def has_results(self, using: str) -> bool: ...
def explain(
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: 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[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: Union[Dict[Any, Any], OrderedDict]
) -> None: ...
def bump_prefix(self, outer_query: Query) -> None: ...
def get_initial_alias(self) -> str: ...
def count_active_tables(self) -> int: ...
def join(
self,
join: Union[BaseTable, Join],
reuse: Optional[Set[str]] = ...,
reuse_with_filtered_relation: bool = ...,
) -> str: ...
def join_parent_model(
self,
opts: Options,
model: Optional[Type[Model]],
alias: str,
seen: Dict[Optional[Type[Model]], str],
) -> str: ...
def add_annotation(
self, annotation: Combinable, alias: str, is_summary: bool = ...
) -> None: ...
def resolve_expression(
self, query: Query, *args: Any, **kwargs: Any
) -> Query: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Tuple]: ...
def resolve_lookup_value(
self, value: Any, can_reuse: Optional[Set[str]], allow_joins: bool
) -> Any: ...
def solve_lookup_type(
self, lookup: str
) -> Union[
Tuple[List[str], List[str], bool], Tuple[List[str], Tuple, Expression]
]: ...
def check_query_object_type(
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,
opts: Options,
) -> None: ...
def build_lookup(
self,
lookups: List[str],
lhs: Union[Expression, TextField, MultiColSource],
rhs: Any,
) -> Lookup: ...
def try_transform(self, lhs: Expression, name: str) -> Transform: ...
def build_filter(
self,
filter_expr: Union[Dict[str, str], Tuple[str, Tuple[int, int]]],
branch_negated: bool = ...,
current_negated: bool = ...,
can_reuse: Optional[Set[str]] = ...,
allow_joins: bool = ...,
split_subq: bool = ...,
reuse_with_filtered_relation: bool = ...,
) -> Tuple[WhereNode, List[Any]]: ...
def add_filter(
self, filter_clause: Tuple[str, Union[List[int], List[str]]]
) -> None: ...
def add_q(self, q_object: Q) -> None: ...
def build_filtered_relation_q(
self,
q_object: Q,
reuse: Set[str],
branch_negated: bool = ...,
current_negated: bool = ...,
) -> WhereNode: ...
def add_filtered_relation(
self, filtered_relation: FilteredRelation, alias: str
) -> None: ...
def names_to_path(
self,
names: List[str],
opts: Options,
allow_many: bool = ...,
fail_on_missing: bool = ...,
) -> Tuple[
List[PathInfo],
Union[Field, reverse_related.ForeignObjectRel],
Tuple[Field],
List[str],
]: ...
def setup_joins(
self,
names: List[str],
opts: Options,
alias: str,
can_reuse: Optional[Set[str]] = ...,
allow_many: bool = ...,
reuse_with_filtered_relation: bool = ...,
) -> JoinInfo: ...
def trim_joins(
self, targets: Tuple[Field], joins: List[str], path: List[PathInfo]
) -> Tuple[Tuple[Field], str, List[str]]: ...
def resolve_ref(
self,
name: str,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
) -> Expression: ...
def split_exclude(
self,
filter_expr: Tuple[str, Union[QuerySet, int]],
can_reuse: Set[str],
names_with_path: List[Tuple[str, List[PathInfo]]],
) -> Tuple[WhereNode, Tuple]: ...
def set_empty(self) -> None: ...
def is_empty(self) -> bool: ...
high_mark: Optional[int] = ...
low_mark: int = ...
def set_limits(
self, low: Optional[int] = ..., high: Optional[int] = ...
) -> None: ...
def clear_limits(self) -> None: ...
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[Expression]) -> None: ...
def add_distinct_fields(self, *field_names: Any) -> None: ...
def add_fields(
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]) -> None: ...
def add_extra(
self,
select: Optional[Union[Dict[str, int], Dict[str, str], OrderedDict]],
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: Tuple[str]) -> None: ...
def add_immediate_loading(self, field_names: Tuple[str]) -> None: ...
def get_loaded_field_names(self) -> Dict[Type[Model], Set[str]]: ...
def get_loaded_field_names_cb(
self,
target: Dict[Type[Model], Set[str]],
model: Type[Model],
fields: Union[Set[Field], Set[reverse_related.ManyToOneRel]],
) -> 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) -> Union[Dict[Any, Any], OrderedDict]: ...
@property
def extra_select(self) -> Union[Dict[Any, Any], OrderedDict]: ...
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: 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[Iterator[Any], List[Any], Set[str], Tuple]
) -> None: ...
def update_join_types(self, query: Query) -> Set[str]: ...

View File

@@ -0,0 +1,227 @@
from typing import Any, Dict, List, Optional, Tuple, Type, Union
from django.db.models.base import Model
from django.db.models.expressions import Case
from django.db.models.fields import DateTimeCheckMixin, Field
from django.db.models.query import QuerySet
from django.db.models.sql.query import Query
from django.db.models.sql.where import WhereNode
from django.utils.datastructures import ImmutableList
class DeleteQuery(Query):
alias_refcount: Dict[str, int]
annotation_select_mask: None
base_table: str
combinator: None
combinator_all: bool
combined_queries: Tuple
default_cols: bool
default_ordering: bool
deferred_loading: Tuple[frozenset, bool]
distinct: bool
distinct_fields: Tuple
explain_format: None
explain_options: Dict[Any, Any]
explain_query: bool
external_aliases: Set[Any]
extra_order_by: Tuple
extra_select_mask: None
extra_tables: Tuple
filter_is_sticky: bool
group_by: None
high_mark: None
low_mark: int
max_depth: int
model: Type[django.db.models.base.Model]
order_by: Tuple
select: Tuple
select_for_update: bool
select_for_update_nowait: bool
select_for_update_of: Tuple
select_for_update_skip_locked: bool
select_related: bool
standard_ordering: bool
subq_aliases: frozenset
subquery: bool
table_map: Dict[str, List[str]]
used_aliases: Set[str]
values_select: Tuple
where_class: Type[django.db.models.sql.where.WhereNode]
compiler: str = ...
alias_map: Union[
Dict[str, django.db.models.sql.datastructures.BaseTable],
collections.OrderedDict,
] = ...
where: django.db.models.sql.where.WhereNode = ...
def do_query(self, table: str, where: WhereNode, using: str) -> int: ...
def delete_batch(
self, pk_list: Union[List[int], List[str]], using: str
) -> int: ...
def delete_qs(self, query: QuerySet, using: str) -> int: ...
class UpdateQuery(Query):
alias_map: collections.OrderedDict
alias_refcount: Dict[str, int]
annotation_select_mask: Optional[Set[Any]]
base_table: str
combinator: None
combinator_all: bool
combined_queries: Tuple
default_cols: bool
default_ordering: bool
deferred_loading: Tuple[frozenset, bool]
distinct: bool
distinct_fields: Tuple
explain_format: None
explain_options: Dict[Any, Any]
explain_query: bool
external_aliases: Set[Any]
extra_order_by: Tuple
extra_select_mask: Optional[Set[Any]]
extra_tables: Tuple
filter_is_sticky: bool
group_by: Optional[bool]
high_mark: None
low_mark: int
max_depth: int
model: Type[django.db.models.base.Model]
order_by: Tuple
related_ids: Optional[List[int]]
related_updates: Dict[
Type[django.db.models.base.Model],
List[Tuple[django.db.models.fields.Field, None, Union[int, str]]],
]
select: Tuple
select_for_update: bool
select_for_update_nowait: bool
select_for_update_of: Tuple
select_for_update_skip_locked: bool
select_related: bool
standard_ordering: bool
subq_aliases: frozenset
subquery: bool
table_map: Dict[str, List[str]]
used_aliases: Set[str]
values: List[
Tuple[
django.db.models.fields.Field,
Optional[Type[django.db.models.base.Model]],
Union[django.db.models.expressions.Case, uuid.UUID],
]
]
values_select: Tuple
where_class: Type[django.db.models.sql.where.WhereNode]
compiler: str = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clone(self) -> UpdateQuery: ...
where: django.db.models.sql.where.WhereNode = ...
def update_batch(
self, pk_list: List[int], values: Dict[str, Optional[int]], using: str
) -> None: ...
def add_update_values(self, values: Dict[str, Any]) -> None: ...
def add_update_fields(
self, values_seq: List[Tuple[Field, Optional[Type[Model]], Case]]
) -> None: ...
def add_related_update(
self, model: Type[Model], field: Field, value: Union[int, str]
) -> None: ...
def get_related_updates(self) -> List[UpdateQuery]: ...
class InsertQuery(Query):
alias_map: collections.OrderedDict
alias_refcount: Dict[str, int]
annotation_select_mask: None
combinator: None
combinator_all: bool
combined_queries: Tuple
default_cols: bool
default_ordering: bool
deferred_loading: Tuple[frozenset, bool]
distinct: bool
distinct_fields: Tuple
explain_format: None
explain_options: Dict[Any, Any]
explain_query: bool
external_aliases: Set[Any]
extra_order_by: Tuple
extra_select_mask: None
extra_tables: Tuple
filter_is_sticky: bool
group_by: None
high_mark: None
low_mark: int
max_depth: int
model: Type[django.db.models.base.Model]
order_by: Tuple
select: Tuple
select_for_update: bool
select_for_update_nowait: bool
select_for_update_of: Tuple
select_for_update_skip_locked: bool
select_related: bool
standard_ordering: bool
subquery: bool
table_map: Dict[str, List[str]]
used_aliases: Set[Any]
values_select: Tuple
where: django.db.models.sql.where.WhereNode
where_class: Type[django.db.models.sql.where.WhereNode]
compiler: str = ...
fields: Union[
List[django.db.models.fields.DateTimeCheckMixin],
List[django.db.models.fields.Field],
django.utils.datastructures.ImmutableList,
] = ...
objs: List[django.db.models.base.Model] = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
raw: bool = ...
def insert_values(
self,
fields: Union[List[DateTimeCheckMixin], List[Field], ImmutableList],
objs: List[Model],
raw: bool = ...,
) -> None: ...
class AggregateQuery(Query):
alias_map: collections.OrderedDict
alias_refcount: Dict[Any, Any]
annotation_select_mask: None
combinator: None
combinator_all: bool
combined_queries: Tuple
default_cols: bool
default_ordering: bool
deferred_loading: Tuple[frozenset, bool]
distinct: bool
distinct_fields: Tuple
explain_format: None
explain_options: Dict[Any, Any]
explain_query: bool
external_aliases: Set[Any]
extra_order_by: Tuple
extra_select_mask: None
extra_tables: Tuple
filter_is_sticky: bool
group_by: None
high_mark: None
low_mark: int
max_depth: int
model: Type[django.db.models.base.Model]
order_by: Tuple
select: Tuple
select_for_update: bool
select_for_update_nowait: bool
select_for_update_of: Tuple
select_for_update_skip_locked: bool
select_related: bool
standard_ordering: bool
sub_params: Tuple
subquery: Union[bool, str]
table_map: Dict[Any, Any]
used_aliases: Set[Any]
values_select: Tuple
where: django.db.models.sql.where.WhereNode
where_class: Type[django.db.models.sql.where.WhereNode]
compiler: str = ...
def add_subquery(self, query: Query, using: str) -> None: ...

View File

@@ -0,0 +1,89 @@
from collections import OrderedDict
from typing import Any, Dict, List, Optional, Tuple, Union
from django.db import DefaultConnectionProxy
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.expressions import Expression
from django.db.models.lookups import FieldGetDbPrepValueMixin
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.query import Query
from django.utils import tree
AND: str
OR: str
class WhereNode(tree.Node):
connector: str
contains_aggregate: bool
contains_over_clause: bool
negated: bool
default: Any = ...
resolved: bool = ...
conditional: bool = ...
def split_having(
self, negated: bool = ...
) -> Tuple[Optional[WhereNode], Optional[WhereNode]]: ...
def as_sql(
self,
compiler: SQLCompiler,
connection: Union[DefaultConnectionProxy, DatabaseWrapper],
) -> Tuple[str, List[Union[int, str]]]: ...
def get_group_by_cols(self) -> List[Expression]: ...
def get_source_expressions(self) -> List[FieldGetDbPrepValueMixin]: ...
children: List[
Union[
django.db.models.lookups.BuiltinLookup,
django.db.models.sql.where.WhereNode,
]
] = ...
def set_source_expressions(
self, children: List[FieldGetDbPrepValueMixin]
) -> None: ...
def relabel_aliases(
self, change_map: Union[Dict[Optional[str], str], OrderedDict]
) -> None: ...
def clone(self) -> WhereNode: ...
def relabeled_clone(
self, change_map: Union[Dict[Optional[str], str], OrderedDict]
) -> WhereNode: ...
def contains_aggregate(self) -> bool: ...
def contains_over_clause(self) -> bool: ...
@property
def is_summary(self): ...
def resolve_expression(self, *args: Any, **kwargs: Any) -> WhereNode: ...
class NothingNode:
contains_aggregate: bool = ...
def as_sql(
self,
compiler: SQLCompiler = ...,
connection: Union[DefaultConnectionProxy, DatabaseWrapper] = ...,
) -> Any: ...
class ExtraWhere:
contains_aggregate: bool = ...
sqls: List[str] = ...
params: Optional[Union[List[int], List[str]]] = ...
def __init__(
self, sqls: List[str], params: Optional[Union[List[int], List[str]]]
) -> None: ...
def as_sql(
self, compiler: SQLCompiler = ..., connection: DatabaseWrapper = ...
) -> Tuple[str, Union[List[int], List[str]]]: ...
class SubqueryConstraint:
contains_aggregate: bool = ...
alias: str = ...
columns: List[str] = ...
targets: List[str] = ...
query_object: django.db.models.sql.query.Query = ...
def __init__(
self,
alias: str,
columns: List[str],
targets: List[str],
query_object: Query,
) -> None: ...
def as_sql(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Tuple]: ...

View File

@@ -0,0 +1,6 @@
from typing import Any, Optional, Tuple, Type, Union
from django.db.models.base import Model
def make_model_tuple(model: Union[Type[Model], str]) -> Tuple[str, str]: ...