add missing files throughout the codebase (#102)

This commit is contained in:
Maxim Kurnikov
2019-07-09 05:18:15 +03:00
committed by GitHub
parent d8230a4147
commit 2799646723
67 changed files with 748 additions and 120 deletions
+2 -1
View File
@@ -27,4 +27,5 @@ class DefaultConnectionProxy:
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
def close_old_connections(**kwargs): ...
def close_old_connections(**kwargs: Any) -> None: ...
def reset_queries(**kwargs: Any) -> None: ...
+1 -1
View File
@@ -25,7 +25,7 @@ class BaseDatabaseOperations:
CURRENT_ROW: str = ...
explain_prefix: Any = ...
connection: Any = ...
def __init__(self, connection: Union[DefaultConnectionProxy, BaseDatabaseWrapper]) -> None: ...
def __init__(self, connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]]) -> None: ...
def autoinc_sql(self, table: str, column: str) -> None: ...
def bulk_batch_size(self, fields: Any, objs: Any): ...
def cache_key_culling_sql(self) -> str: ...
@@ -0,0 +1,17 @@
from typing import Dict, Tuple
from django.db.backends.base.base import BaseDatabaseWrapper
def psycopg2_version() -> Tuple[int, ...]: ...
PSYCOPG2_VERSION: Tuple[int, ...] = ...
class DatabaseWrapper(BaseDatabaseWrapper):
operators: Dict[str, str] = ...
pattern_esc: str = ...
pattern_ops: Dict[str, str] = ...
# PostgreSQL backend-specific attributes.
_named_cursor_idx: int = ...
@property
def pg_version(self) -> str: ...
@@ -0,0 +1,3 @@
from django.db.backends.base.creation import BaseDatabaseCreation
class DatabaseCreation(BaseDatabaseCreation): ...
@@ -0,0 +1,3 @@
from django.db.backends.base.operations import BaseDatabaseOperations
class DatabaseOperations(BaseDatabaseOperations): ...
+3
View File
@@ -0,0 +1,3 @@
from django.dispatch import Signal
connection_created: Signal = ...
@@ -16,41 +16,7 @@ from .models import (
DeleteModel as DeleteModel,
RemoveIndex as RemoveIndex,
RenameModel as RenameModel,
AddConstraint as AddConstraint,
RemoveConstraint as RemoveConstraint,
)
from .special import RunPython as RunPython, RunSQL as RunSQL, SeparateDatabaseAndState as SeparateDatabaseAndState
from .fields import AddField, AlterField, RemoveField, RenameField
from .models import (
AddIndex,
AlterIndexTogether,
AlterModelManagers,
AlterModelOptions,
AlterModelTable,
AlterOrderWithRespectTo,
AlterUniqueTogether,
CreateModel,
DeleteModel,
RemoveIndex,
RenameModel,
)
from .special import RunPython, RunSQL, SeparateDatabaseAndState
__all__ = [
"CreateModel",
"DeleteModel",
"AlterModelTable",
"AlterUniqueTogether",
"RenameModel",
"AlterIndexTogether",
"AlterModelOptions",
"AddIndex",
"RemoveIndex",
"AddField",
"RemoveField",
"AlterField",
"RenameField",
"SeparateDatabaseAndState",
"RunSQL",
"RunPython",
"AlterOrderWithRespectTo",
"AlterModelManagers",
]
@@ -4,6 +4,7 @@ from django.db.migrations.operations.base import Operation
from django.db.models.indexes import Index
from django.db.models.manager import Manager
from django.db.models.constraints import BaseConstraint
from django.db.models.fields import Field
class ModelOperation(Operation):
@@ -78,3 +79,9 @@ class RemoveIndex(IndexOperation):
model_name: str = ...
name: str = ...
def __init__(self, model_name: str, name: Union[str, Index]) -> None: ...
class AddConstraint(IndexOperation):
def __init__(self, model_name: str, constraint: BaseConstraint): ...
class RemoveConstraint(IndexOperation):
def __init__(self, model_name: str, name: str) -> None: ...
+7 -1
View File
@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Set, Tuple, Union
from typing import Any, Callable, Dict, List, Set, Tuple, Union, Type
class BaseSerializer:
value: Any = ...
@@ -38,3 +38,9 @@ class TypeSerializer(BaseSerializer): ...
class UUIDSerializer(BaseSerializer): ...
def serializer_factory(value: Any) -> BaseSerializer: ...
class Serializer:
@classmethod
def register(cls, type_: type, serializer: Type[BaseSerializer]) -> None: ...
@classmethod
def unregister(cls, type_: type) -> None: ...
+4 -1
View File
@@ -1,4 +1,4 @@
from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union
from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, Set
from django.apps.registry import Apps
from django.db.models.base import Model
@@ -42,6 +42,9 @@ class ModelState:
def name_lower(self) -> str: ...
def render(self, apps: Apps) -> Any: ...
def get_related_models_tuples(model: Type[Model]) -> Set[Tuple[str, str]]: ...
def get_related_models_recursive(model: Type[Model]) -> Set[Tuple[str, str]]: ...
class ProjectState:
is_delayed: bool
models: Dict[Any, Any]
+1 -1
View File
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Iterable, Union, Optional, List
COMPILED_REGEX_TYPE: Any
+6 -1
View File
@@ -1,8 +1,9 @@
from typing import Any, List, Set, Tuple, Union
from typing import Any, List, Set, Tuple, Union, Type
from django.db.migrations.migration import Migration
from django.db.migrations.operations.base import Operation
from django.db.migrations.operations.models import CreateModel
from django.db.migrations.serializer import BaseSerializer
class SettingsReference(str):
def __init__(self, value: str, setting_name: str) -> None: ...
@@ -31,5 +32,9 @@ class MigrationWriter:
def path(self) -> str: ...
@classmethod
def serialize(cls, value: Any) -> Tuple[str, Set[str]]: ...
@classmethod
def register_serializer(cls, type_: type, serializer: Type[BaseSerializer]) -> None: ...
@classmethod
def unregister_serializer(cls, type_: type) -> None: ...
MIGRATION_TEMPLATE: str
+10
View File
@@ -99,6 +99,10 @@ from .expressions import (
ExpressionList as ExpressionList,
Random as Random,
Ref as Ref,
Window as Window,
WindowFrame as WindowFrame,
RowRange as RowRange,
ValueRange as ValueRange,
)
from .manager import BaseManager as BaseManager, Manager as Manager
@@ -118,3 +122,9 @@ from .aggregates import (
from .indexes import Index as Index
from . import signals as signals
from .constraints import (
BaseConstraint as BaseConstraint,
CheckConstraint as CheckConstraint,
UniqueConstraint as UniqueConstraint,
)
+5
View File
@@ -1,7 +1,10 @@
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union
from django.core import checks
from django.db.models.manager import Manager
from django.core.checks.messages import CheckMessage
class ModelBase(type): ...
_Self = TypeVar("_Self", bound="Model")
@@ -36,6 +39,8 @@ class Model(metaclass=ModelBase):
): ...
def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> _Self: ...
def get_deferred_fields(self) -> Set[str]: ...
@classmethod
def check(cls, **kwargs: Any) -> List[CheckMessage]: ...
def __getstate__(self) -> dict: ...
class ModelStateFieldsCacheDescriptor: ...
+27
View File
@@ -0,0 +1,27 @@
from typing import Any, Optional, Sequence, Tuple, Type, TypeVar
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.models.base import Model
from django.db.models.query_utils import Q
_T = TypeVar("_T", bound="BaseConstraint")
class BaseConstraint:
name: str
def __init__(self, name: str) -> None: ...
def constraint_sql(
self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]
) -> str: ...
def create_sql(self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]) -> str: ...
def remove_sql(self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]) -> str: ...
def deconstruct(self) -> Any: ...
def clone(self: _T) -> _T: ...
class CheckConstraint(BaseConstraint):
check: Q
def __init__(self, *, check: Q, name: str) -> None: ...
class UniqueConstraint(BaseConstraint):
fields: Tuple[str]
condition: Optional[Q]
def __init__(self, *, fields: Sequence[str], name: str, condition: Optional[Q] = ...): ...
+4 -1
View File
@@ -1,4 +1,6 @@
from typing import Any, Callable, Iterable
from typing import Any, Callable, Iterable, Optional, Union
from django.db.models.base import Model
from django.db import IntegrityError
from django.db.models.fields import Field
@@ -16,3 +18,4 @@ class ProtectedError(IntegrityError): ...
class Collector:
def __init__(self, using: str) -> None: ...
def can_fast_delete(self, objs: Union[Model, Iterable[Model]], from_field: Optional[Field] = ...) -> bool: ...
+29 -3
View File
@@ -1,5 +1,5 @@
from datetime import datetime, timedelta
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, Iterable
from django.db.models.lookups import Lookup
from django.db.models.sql.compiler import SQLCompiler
@@ -184,10 +184,36 @@ class ExpressionWrapper(Expression):
class Col(Expression):
def __init__(self, alias: str, target: str, output_field: Optional[_OutputField] = ...): ...
class SimpleCol(Expression):
contains_column_references: bool = ...
def __init__(self, target: Field, output_field: Optional[_OutputField] = ...): ...
class Ref(Expression):
def __init__(self, refs: str, source: Expression): ...
class ExpressionList(Func):
def __init__(self, *expressions: Union[BaseExpression, Combinable], **extra: Any) -> None: ...
class Random(Expression): ...
class Ref(Expression):
def __init__(self, refs: str, source: Expression): ...
class Window(Expression):
template: str = ...
contains_aggregate: bool = ...
contains_over_clause: bool = ...
def __init__(
self,
expression: BaseExpression,
partition_by: Optional[Union[str, Iterable[Union[BaseExpression, F]], F, BaseExpression]] = ...,
order_by: Optional[Union[Sequence[Union[BaseExpression, F]], Union[BaseExpression, F]]] = ...,
frame: Optional[WindowFrame] = ...,
output_field: Optional[_OutputField] = ...,
) -> None: ...
class WindowFrame(Expression):
template: str = ...
frame_type: str = ...
def __init__(self, start: Optional[int] = ..., end: Optional[int] = ...) -> None: ...
def window_frame_start_end(self, connection: Any, start: Optional[int], end: Optional[int]) -> Tuple[int, int]: ...
class RowRange(WindowFrame): ...
class ValueRange(WindowFrame): ...
+14 -1
View File
@@ -1,7 +1,7 @@
import decimal
import uuid
from datetime import date, datetime, time, timedelta
from typing import Any, Callable, Dict, Generic, Iterable, Optional, Tuple, Type, TypeVar, Union
from typing import Any, Callable, Dict, Generic, Iterable, Optional, Tuple, Type, TypeVar, Union, Sequence
from django.db.models import Model
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
@@ -34,6 +34,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
max_length: Optional[int]
model: Type[Model]
name: str
blank: bool = ...
null: bool = ...
editable: bool = ...
choices: Optional[_FieldChoices] = ...
def __init__(
self,
verbose_name: Optional[Union[str, bytes]] = ...,
@@ -69,6 +73,15 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
def formfield(self, **kwargs) -> FormField: ...
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
def to_python(self, value: Any) -> Any: ...
def clean(self, value: Any, model_instance: Optional[Model]) -> Any: ...
def get_choices(
self,
include_blank: bool = ...,
blank_choice: _Choice = ...,
limit_choices_to: Optional[Any] = ...,
ordering: Sequence[str] = ...,
) -> Sequence[Union[_Choice, _ChoiceNamedGroup]]: ...
def get_default(self) -> Any: ...
class IntegerField(Field[_ST, _GT]):
_pyi_private_set_type: Union[float, int, str, Combinable]
+2 -8
View File
@@ -62,7 +62,6 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
def related_model(self) -> Union[Type[Model], str]: ...
def check(self, **kwargs: Any) -> List[Any]: ...
opts: Any = ...
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
@@ -76,7 +75,7 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
@property
def target_field(self) -> Field: ...
class ForeignObject(RelatedField):
class ForeignObject(RelatedField[_ST, _GT]):
def __init__(
self,
to: Union[Type[Model], str],
@@ -109,7 +108,7 @@ class ForeignObject(RelatedField):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class ForeignKey(RelatedField[_ST, _GT]):
class ForeignKey(ForeignObject[_ST, _GT]):
_pyi_private_set_type: Union[Any, Combinable]
_pyi_private_get_type: Any
def __init__(
@@ -185,10 +184,6 @@ class ManyToManyField(RelatedField[_ST, _GT]):
_pyi_private_set_type: Sequence[Any]
_pyi_private_get_type: RelatedManager[Any]
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 = ...
@@ -228,7 +223,6 @@ class ManyToManyField(RelatedField[_ST, _GT]):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
) -> 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 = ...
+27 -1
View File
@@ -17,6 +17,7 @@ from .text import (
StrIndex as StrIndex,
Replace as Replace,
Substr as Substr,
Reverse as Reverse,
)
from .window import (
@@ -44,6 +45,7 @@ from .datetime import (
ExtractWeek as ExtractWeek,
ExtractWeekDay as ExtractWeekDay,
ExtractYear as ExtractYear,
ExtractIsoYear as ExtractIsoYear,
Trunc as Trunc,
TruncDate as TruncDate,
TruncDay as TruncDay,
@@ -58,4 +60,28 @@ from .datetime import (
Now as Now,
)
from .comparison import Coalesce as Coalesce, Greatest as Greatest, Least as Least, Cast as Cast
from .comparison import Coalesce as Coalesce, Greatest as Greatest, Least as Least, Cast as Cast, NullIf as NullIf
from .math import (
Abs as Abs,
ACos as ACos,
ASin as ASin,
ATan as ATan,
ATan2 as ATan2,
Ceil as Ceil,
Cos as Cos,
Cot as Cot,
Degrees as Degrees,
Floor as Floor,
Exp as Exp,
Ln as Ln,
Log as Log,
Mod as Mod,
Pi as Pi,
Power as Power,
Radians as Radians,
Round as Round,
Sin as Sin,
Sqrt as Sqrt,
Tan as Tan,
)
@@ -9,3 +9,4 @@ class Cast(Func):
class Coalesce(Func): ...
class Greatest(Func): ...
class Least(Func): ...
class NullIf(Func): ...
@@ -8,6 +8,7 @@ class TimezoneMixin:
class Extract(TimezoneMixin, Transform): ...
class ExtractYear(Extract): ...
class ExtractIsoYear(Extract): ...
class ExtractMonth(Extract): ...
class ExtractDay(Extract): ...
class ExtractWeek(Extract): ...
+25
View File
@@ -0,0 +1,25 @@
from django.db.models.expressions import Func
from django.db.models.functions.mixins import FixDecimalInputMixin, NumericOutputFieldMixin
from django.db.models.lookups import Transform
class Abs(Transform): ...
class ACos(NumericOutputFieldMixin, Transform): ...
class ASin(NumericOutputFieldMixin, Transform): ...
class ATan(NumericOutputFieldMixin, Transform): ...
class ATan2(NumericOutputFieldMixin, Func): ...
class Ceil(Transform): ...
class Cos(NumericOutputFieldMixin, Transform): ...
class Cot(NumericOutputFieldMixin, Transform): ...
class Degrees(NumericOutputFieldMixin, Transform): ...
class Exp(NumericOutputFieldMixin, Transform): ...
class Floor(Transform): ...
class Ln(NumericOutputFieldMixin, Transform): ...
class Log(FixDecimalInputMixin, NumericOutputFieldMixin, Func): ...
class Mod(FixDecimalInputMixin, NumericOutputFieldMixin, Func): ...
class Pi(NumericOutputFieldMixin, Func): ...
class Power(NumericOutputFieldMixin, Func): ...
class Radians(NumericOutputFieldMixin, Transform): ...
class Round(Transform): ...
class Sin(NumericOutputFieldMixin, Transform): ...
class Sqrt(NumericOutputFieldMixin, Transform): ...
class Tan(NumericOutputFieldMixin, Transform): ...
@@ -0,0 +1,3 @@
class FixDecimalInputMixin: ...
class FixDurationInputMixin: ...
class NumericOutputFieldMixin: ...
@@ -54,3 +54,4 @@ class Substr(Func):
class Trim(Transform): ...
class Upper(Transform): ...
class Reverse(Transform): ...
+2
View File
@@ -105,3 +105,5 @@ class SQLCompiler:
) -> Optional[Any]: ...
def as_subquery_condition(self, alias: str, columns: List[str], compiler: SQLCompiler) -> Tuple[str, Tuple]: ...
def explain_query(self) -> Iterator[str]: ...
def cursor_iter(cursor: Any, sentinel: Any, col_count: Optional[int], itersize: int) -> Iterator[Any]: ...
+3
View File
@@ -9,6 +9,7 @@ from django.db.models.sql.datastructures import BaseTable
from django.db.models.sql.where import WhereNode
from django.db.models import Expression, Field, FilteredRelation, Model, Q, QuerySet
from django.db.models.expressions import Combinable
JoinInfo = namedtuple("JoinInfo", ["final_field", "targets", "opts", "joins", "path", "transform_function"])
@@ -46,6 +47,7 @@ class Query:
used_aliases: Set[str] = ...
filter_is_sticky: bool = ...
subquery: bool = ...
group_by: Optional[Union[Sequence[Combinable], Sequence[str], bool]] = ...
order_by: Tuple = ...
distinct: bool = ...
distinct_fields: Tuple = ...
@@ -110,6 +112,7 @@ class Query:
) -> 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_where(self, q_object: Q) -> Any: ...
def build_filtered_relation_q(
self, q_object: Q, reuse: Set[str], branch_negated: bool = ..., current_negated: bool = ...
) -> WhereNode: ...
+11 -8
View File
@@ -1,4 +1,5 @@
from typing import Any, Callable, Optional, overload, TypeVar
from contextlib import contextmanager
from typing import Any, Callable, Optional, overload, TypeVar, Iterator
from django.db import ProgrammingError
@@ -6,16 +7,18 @@ class TransactionManagementError(ProgrammingError): ...
def get_connection(using: Optional[str] = ...) -> Any: ...
def get_autocommit(using: Optional[str] = ...) -> bool: ...
def set_autocommit(autocommit: bool, using: None = ...) -> Any: ...
def commit(using: None = ...) -> Any: ...
def rollback(using: None = ...) -> Any: ...
def savepoint(using: None = ...) -> str: ...
def savepoint_rollback(sid: str, using: None = ...) -> None: ...
def set_autocommit(autocommit: bool, using: Optional[str] = ...) -> Any: ...
def commit(using: Optional[str] = ...) -> Any: ...
def rollback(using: Optional[str] = ...) -> Any: ...
def savepoint(using: Optional[str] = ...) -> str: ...
def savepoint_rollback(sid: str, using: Optional[str] = ...) -> None: ...
def savepoint_commit(sid: Any, using: Optional[Any] = ...) -> None: ...
def clean_savepoints(using: Optional[Any] = ...) -> None: ...
def get_rollback(using: None = ...) -> bool: ...
def get_rollback(using: Optional[str] = ...) -> bool: ...
def set_rollback(rollback: bool, using: Optional[str] = ...) -> None: ...
def on_commit(func: Callable, using: None = ...) -> None: ...
@contextmanager
def mark_for_rollback_on_error(using: Optional[str] = ...) -> Iterator[None]: ...
def on_commit(func: Callable, using: Optional[str] = ...) -> None: ...
_C = TypeVar("_C", bound=Callable) # Any callable
+6 -1
View File
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional
from typing import Any, Dict, Iterable, List, Optional
DEFAULT_DB_ALIAS: str
DJANGO_VERSION_PICKLE_KEY: str
@@ -28,3 +28,8 @@ class ConnectionHandler:
def __iter__(self): ...
def all(self) -> List[Any]: ...
def close_all(self) -> None: ...
class ConnectionRouter:
def __init__(self, routers: Optional[Iterable[Any]] = ...) -> None: ...
@property
def routers(self) -> List[Any]: ...