migrations stubs improvements

This commit is contained in:
Maxim Kurnikov
2018-08-14 12:41:05 +03:00
parent 7df3bf44cb
commit 5e2e5feef4
3 changed files with 185 additions and 100 deletions

View File

@@ -2,7 +2,5 @@
# #
# NOTE: This dynamically typed stub was automatically generated by stubgen. # NOTE: This dynamically typed stub was automatically generated by stubgen.
from .operations import * from .migration import Migration as Migration, swappable_dependency as swappable_dependency
from .migration import Migration, swappable_dependency
from .migration import Migration, swappable_dependency
from .operations import * from .operations import *

View File

@@ -1,6 +1,5 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.postgres.fields.citext import CIText from django.contrib.postgres.fields.citext import CIText
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
from django.db.migrations.operations.base import Operation from django.db.migrations.operations.base import Operation
@@ -9,275 +8,363 @@ from django.db.models.fields import Field
from django.db.models.indexes import Index from django.db.models.indexes import Index
from django.db.models.manager import Manager from django.db.models.manager import Manager
from .fields import (AddField, AlterField, FieldOperation, RemoveField,
RenameField)
class ModelOperation(Operation): class ModelOperation(Operation):
name: Any = ... name: Any = ...
def __init__(self, name: str) -> None: ... def __init__(self, name: str) -> None: ...
def name_lower(self) -> str: ... def name_lower(self) -> str: ...
def references_model( def references_model(
self, name: str, app_label: Optional[str] = ... self, name: str, app_label: Optional[str] = ...
) -> bool: ... ) -> bool: ...
def reduce( def reduce(
self, self,
operation: Operation, operation: Operation,
in_between: List[Operation], in_between: List[Operation],
app_label: str = ..., app_label: str = ...,
) -> bool: ... ) -> bool: ...
class CreateModel(ModelOperation): class CreateModel(ModelOperation):
serialization_expand_args: Any = ... serialization_expand_args: Any = ...
fields: Any = ... fields: Any = ...
options: Any = ... options: Any = ...
bases: Any = ... bases: Any = ...
managers: Any = ... managers: Any = ...
def __init__( def __init__(
self, self,
name: str, name: str,
fields: List[Tuple[str, Union[CIText, Field]]], fields: List[Tuple[str, Union[CIText, Field]]],
options: Optional[ options: Optional[Dict[str, Any]] = ...,
Union[ bases: Optional[
Dict[str, Union[Set[Tuple[str, str]], Tuple[str], str]], Union[Tuple[Type[Any], ...],
Dict[str, Union[bool, str]], Tuple[str, ...]]] = ...,
] managers: Optional[List[Tuple[str, Manager]]] = ...,
] = ...,
bases: Optional[Tuple[Type[AbstractBaseUser]]] = ...,
managers: Optional[List[Tuple[str, Manager]]] = ...,
) -> None: ... ) -> None: ...
def deconstruct( def deconstruct(
self self
) -> Tuple[ ) -> Tuple[
str, str,
List[Any], List[Any],
Dict[str, Union[Dict[str, str], List[Tuple[str, Field]], str]], Dict[str, Union[Dict[str, str], List[Tuple[str, Field]], str]],
]: ... ]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ... def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards( def database_forwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def describe(self) -> str: ... def describe(self) -> str: ...
def references_model(self, name: str, app_label: str = ...) -> bool: ... def references_model(self, name: str, app_label: str = ...) -> bool: ...
def model_to_key(self, model: str) -> List[str]: ... def model_to_key(self, model: str) -> List[str]: ...
def reduce( def reduce(
self, self,
operation: Operation, operation: Operation,
in_between: List[Operation], in_between: List[Operation],
app_label: str = ..., app_label: str = ...,
) -> Union[List[CreateModel], bool]: ... ) -> Union[List[CreateModel], bool]: ...
class DeleteModel(ModelOperation): class DeleteModel(ModelOperation):
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ... def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ... def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards( def database_forwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def describe(self) -> str: ... def describe(self) -> str: ...
class RenameModel(ModelOperation): class RenameModel(ModelOperation):
old_name: Any = ... old_name: Any = ...
new_name: Any = ... new_name: Any = ...
def __init__(self, old_name: str, new_name: str) -> None: ... def __init__(self, old_name: str, new_name: str) -> None: ...
def old_name_lower(self) -> str: ... def old_name_lower(self) -> str: ...
def new_name_lower(self) -> str: ... def new_name_lower(self) -> str: ...
def deconstruct(self): ... def deconstruct(self): ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ... def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards( def database_forwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def references_model(self, name: Any, app_label: Optional[Any] = ...): ... def references_model(self, name: Any, app_label: Optional[Any] = ...): ...
def describe(self): ... def describe(self): ...
def reduce( def reduce(
self, self,
operation: AlterModelTable, operation: AlterModelTable,
in_between: List[Any], in_between: List[Any],
app_label: str = ..., app_label: str = ...,
) -> bool: ... ) -> bool: ...
class AlterModelTable(ModelOperation): class AlterModelTable(ModelOperation):
table: Any = ... table: Any = ...
def __init__(self, name: str, table: Optional[str]) -> None: ... def __init__(self, name: str, table: Optional[str]) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
): ... ): ...
def describe(self): ... def describe(self): ...
def reduce( def reduce(
self, operation: Any, in_between: Any, app_label: Optional[Any] = ... self, operation: Any, in_between: Any, app_label: Optional[Any] = ...
): ... ): ...
class ModelOptionOperation(ModelOperation): class ModelOptionOperation(ModelOperation):
def reduce( def reduce(
self, self,
operation: Operation, operation: Operation,
in_between: List[DeleteModel], in_between: List[DeleteModel],
app_label: str = ..., app_label: str = ...,
) -> bool: ... ) -> bool: ...
class FieldRelatedOptionOperation(ModelOptionOperation): class FieldRelatedOptionOperation(ModelOptionOperation):
def reduce( def reduce(
self, operation: Operation, in_between: List[Any], app_label: str = ... self, operation: Operation, in_between: List[Any], app_label: str = ...
) -> Union[List[Operation], bool]: ... ) -> Union[List[Operation], bool]: ...
class AlterUniqueTogether(FieldRelatedOptionOperation): class AlterUniqueTogether(FieldRelatedOptionOperation):
option_name: str = ... option_name: str = ...
unique_together: Any = ... unique_together: Any = ...
def __init__( def __init__(
self, name: str, unique_together: Set[Tuple[str, str]] self, name: str, unique_together: Set[Tuple[str, ...]]
) -> None: ... ) -> None: ...
def deconstruct( def deconstruct(
self self
) -> Tuple[str, List[Any], Dict[str, Union[Set[Tuple[str, str]], str]]]: ... ) -> Tuple[str, List[Any], Dict[str, Union[Set[Tuple[str, str]], str]]]: ...
def state_forwards(self, app_label: str, state: ProjectState) -> None: ... def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
def database_forwards( def database_forwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, self,
app_label: str, app_label: str,
schema_editor: DatabaseSchemaEditor, schema_editor: DatabaseSchemaEditor,
from_state: ProjectState, from_state: ProjectState,
to_state: ProjectState, to_state: ProjectState,
) -> None: ... ) -> None: ...
def references_field( def references_field(
self, model_name: str, name: str, app_label: Optional[str] = ... self, model_name: str, name: str, app_label: Optional[str] = ...
) -> bool: ... ) -> bool: ...
def describe(self) -> str: ... def describe(self) -> str: ...
class AlterIndexTogether(FieldRelatedOptionOperation): class AlterIndexTogether(FieldRelatedOptionOperation):
option_name: str = ... option_name: str = ...
index_together: Any = ... index_together: Any = ...
def __init__( def __init__(
self, name: str, index_together: Set[Tuple[str, str]] self, name: str, index_together: Set[Tuple[str, str]]
) -> None: ... ) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
): ... ): ...
def references_field( def references_field(
self, model_name: str, name: str, app_label: Optional[str] = ... self, model_name: str, name: str, app_label: Optional[str] = ...
) -> bool: ... ) -> bool: ...
def describe(self): ... def describe(self): ...
class AlterOrderWithRespectTo(FieldRelatedOptionOperation): class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
name: str name: str
order_with_respect_to: str = ... order_with_respect_to: str = ...
def __init__(self, name: str, order_with_respect_to: str) -> None: ... def __init__(self, name: str, order_with_respect_to: str) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def references_field( def references_field(
self, model_name: str, name: str, app_label: None = ... self, model_name: str, name: str, app_label: None = ...
) -> bool: ... ) -> bool: ...
def describe(self): ... def describe(self): ...
class AlterModelOptions(ModelOptionOperation): class AlterModelOptions(ModelOptionOperation):
ALTER_OPTION_KEYS: Any = ... ALTER_OPTION_KEYS: Any = ...
options: Any = ... options: Any = ...
def __init__(self, name: str, options: Dict[str, str]) -> None: ... def __init__(self, name: str, options: Dict[str, str]) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def describe(self): ... def describe(self): ...
class AlterModelManagers(ModelOptionOperation): class AlterModelManagers(ModelOptionOperation):
serialization_expand_args: Any = ... serialization_expand_args: Any = ...
managers: Any = ... managers: Any = ...
def __init__(self, name: Any, managers: Any) -> None: ... def __init__(self, name: Any, managers: Any) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def describe(self): ... def describe(self): ...
class IndexOperation(Operation): class IndexOperation(Operation):
option_name: str = ... option_name: str = ...
def model_name_lower(self): ... def model_name_lower(self): ...
class AddIndex(IndexOperation): class AddIndex(IndexOperation):
model_name: str = ... model_name: str = ...
index: django.db.models.indexes.Index = ... index: django.db.models.indexes.Index = ...
def __init__(self, model_name: str, index: Index) -> None: ... def __init__(self, model_name: str, index: Index) -> None: ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def describe(self): ... def describe(self): ...
class RemoveIndex(IndexOperation): class RemoveIndex(IndexOperation):
model_name: str = ... model_name: str = ...
name: str = ... name: str = ...
def __init__(self, model_name: str, name: str) -> None: ... def __init__(self, model_name: str, name: str) -> None: ...
def state_forwards(self, app_label: Any, state: Any) -> None: ... def state_forwards(self, app_label: Any, state: Any) -> None: ...
def database_forwards( def database_forwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def database_backwards( def database_backwards(
self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any
) -> None: ... ) -> None: ...
def deconstruct(self): ... def deconstruct(self): ...
def describe(self): ... def describe(self): ...

View File

@@ -1,5 +1,5 @@
from contextlib import ContextDecorator from contextlib import ContextDecorator
from typing import Any, Callable, Optional, Union from typing import Any, Callable, Optional, Union, ContextManager
from django.db import ProgrammingError from django.db import ProgrammingError
from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper
@@ -31,5 +31,5 @@ class Atomic(ContextDecorator):
def atomic( def atomic(
using: Optional[Union[Callable, str]] = ..., savepoint: bool = ... using: Optional[Union[Callable, str]] = ..., savepoint: bool = ...
) -> Callable: ... ) -> ContextManager[Atomic]: ...
def non_atomic_requests(using: Callable = ...) -> Callable: ... def non_atomic_requests(using: Callable = ...) -> Callable: ...