mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 12:44:29 +08:00
add django.db.migrations
This commit is contained in:
@@ -10,9 +10,9 @@ from django.db.models.fields import Field
|
||||
from .topological_sort import stable_topological_sort
|
||||
|
||||
class MigrationAutodetector:
|
||||
from_state: django.db.migrations.state.ProjectState = ...
|
||||
to_state: django.db.migrations.state.ProjectState = ...
|
||||
questioner: django.db.migrations.questioner.MigrationQuestioner = ...
|
||||
from_state: ProjectState = ...
|
||||
to_state: ProjectState = ...
|
||||
questioner: MigrationQuestioner = ...
|
||||
existing_apps: Set[Any] = ...
|
||||
def __init__(
|
||||
self, from_state: ProjectState, to_state: ProjectState, questioner: Optional[MigrationQuestioner] = ...
|
||||
|
||||
@@ -12,8 +12,8 @@ from .state import ProjectState
|
||||
|
||||
class MigrationExecutor:
|
||||
connection: django.db.backends.sqlite3.base.DatabaseWrapper = ...
|
||||
loader: django.db.migrations.loader.MigrationLoader = ...
|
||||
recorder: django.db.migrations.recorder.MigrationRecorder = ...
|
||||
loader: MigrationLoader = ...
|
||||
recorder: MigrationRecorder = ...
|
||||
progress_callback: Callable = ...
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -12,7 +12,7 @@ MIGRATIONS_MODULE_NAME: str
|
||||
|
||||
class MigrationLoader:
|
||||
connection: django.db.backends.sqlite3.base.DatabaseWrapper = ...
|
||||
disk_migrations: Dict[Tuple[str, str], django.db.migrations.migration.Migration] = ...
|
||||
disk_migrations: Dict[Tuple[str, str], Migration] = ...
|
||||
applied_migrations: None = ...
|
||||
ignore_no_migrations: bool = ...
|
||||
def __init__(
|
||||
|
||||
@@ -73,7 +73,7 @@ class StateApps:
|
||||
loading: bool
|
||||
models_ready: bool
|
||||
ready: bool
|
||||
real_models: List[django.db.migrations.state.ModelState]
|
||||
real_models: List[ModelState]
|
||||
stored_app_configs: List[Any]
|
||||
def __init__(
|
||||
self, real_apps: List[str], models: Dict[Tuple[str, str], ModelState], ignore_swappable: bool = ...
|
||||
|
||||
@@ -20,7 +20,7 @@ class OperationWriter:
|
||||
def render(self) -> str: ...
|
||||
|
||||
class MigrationWriter:
|
||||
migration: django.db.migrations.migration.Migration = ...
|
||||
migration: Migration = ...
|
||||
needs_manual_porting: bool = ...
|
||||
def __init__(self, migration: Migration) -> None: ...
|
||||
def as_string(self) -> str: ...
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
from typing import Any
|
||||
|
||||
from .utils import (
|
||||
DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS,
|
||||
DJANGO_VERSION_PICKLE_KEY as DJANGO_VERSION_PICKLE_KEY,
|
||||
ProgrammingError as ProgrammingError,
|
||||
IntegrityError as IntegrityError,
|
||||
OperationalError as OperationalError,
|
||||
DatabaseError as DatabaseError,
|
||||
DataError as DataError,
|
||||
NotSupportedError as NotSupportedError,
|
||||
InternalError as InternalError,
|
||||
InterfaceError as InterfaceError,
|
||||
)
|
||||
|
||||
from . import migrations
|
||||
|
||||
connections: Any
|
||||
router: Any
|
||||
|
||||
|
||||
6
django-stubs/db/migrations/__init__.pyi
Normal file
6
django-stubs/db/migrations/__init__.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
# Stubs for django.db.migrations (Python 3.6)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from .migration import Migration as Migration, swappable_dependency as swappable_dependency
|
||||
from .operations import *
|
||||
67
django-stubs/db/migrations/autodetector.pyi
Normal file
67
django-stubs/db/migrations/autodetector.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
|
||||
|
||||
from django.db.migrations.graph import MigrationGraph
|
||||
from django.db.migrations.migration import Migration
|
||||
from django.db.migrations.operations.base import Operation
|
||||
from django.db.migrations.questioner import MigrationQuestioner
|
||||
from django.db.migrations.state import ProjectState
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class MigrationAutodetector:
|
||||
from_state: ProjectState = ...
|
||||
to_state: ProjectState = ...
|
||||
questioner: MigrationQuestioner = ...
|
||||
existing_apps: Set[Any] = ...
|
||||
def __init__(
|
||||
self, from_state: ProjectState, to_state: ProjectState, questioner: Optional[MigrationQuestioner] = ...
|
||||
) -> None: ...
|
||||
def changes(
|
||||
self,
|
||||
graph: MigrationGraph,
|
||||
trim_to_apps: Optional[Set[str]] = ...,
|
||||
convert_apps: Optional[Set[str]] = ...,
|
||||
migration_name: Optional[str] = ...,
|
||||
) -> Dict[str, List[Migration]]: ...
|
||||
def deep_deconstruct(self, obj: Any) -> Any: ...
|
||||
def only_relation_agnostic_fields(
|
||||
self, fields: List[Tuple[str, Field]]
|
||||
) -> List[Tuple[str, List[Any], Dict[str, Union[Callable, int, str]]]]: ...
|
||||
def check_dependency(
|
||||
self, operation: Operation, dependency: Tuple[str, str, Optional[str], Union[bool, str]]
|
||||
) -> bool: ...
|
||||
def add_operation(
|
||||
self,
|
||||
app_label: str,
|
||||
operation: Operation,
|
||||
dependencies: Optional[List[Tuple[str, str, Optional[str], Union[bool, str]]]] = ...,
|
||||
beginning: bool = ...,
|
||||
) -> None: ...
|
||||
def swappable_first_key(self, item: Tuple[str, str]) -> Tuple[str, str]: ...
|
||||
renamed_models: Any = ...
|
||||
renamed_models_rel: Any = ...
|
||||
def generate_renamed_models(self) -> None: ...
|
||||
def generate_created_models(self) -> None: ...
|
||||
def generate_created_proxies(self) -> None: ...
|
||||
def generate_deleted_models(self) -> None: ...
|
||||
def generate_deleted_proxies(self) -> None: ...
|
||||
renamed_fields: Any = ...
|
||||
def generate_renamed_fields(self) -> None: ...
|
||||
def generate_added_fields(self) -> None: ...
|
||||
def generate_removed_fields(self) -> None: ...
|
||||
def generate_altered_fields(self) -> None: ...
|
||||
def create_altered_indexes(self) -> None: ...
|
||||
def generate_added_indexes(self) -> None: ...
|
||||
def generate_removed_indexes(self) -> None: ...
|
||||
def generate_altered_unique_together(self) -> None: ...
|
||||
def generate_altered_index_together(self) -> None: ...
|
||||
def generate_altered_db_table(self) -> None: ...
|
||||
def generate_altered_options(self) -> None: ...
|
||||
def generate_altered_order_with_respect_to(self) -> None: ...
|
||||
def generate_altered_managers(self) -> None: ...
|
||||
def arrange_for_graph(
|
||||
self, changes: Dict[str, List[Migration]], graph: MigrationGraph, migration_name: Optional[str] = ...
|
||||
) -> Dict[str, List[Migration]]: ...
|
||||
@classmethod
|
||||
def suggest_name(cls, ops: List[Operation]) -> str: ...
|
||||
@classmethod
|
||||
def parse_number(cls, name: str) -> int: ...
|
||||
20
django-stubs/db/migrations/exceptions.pyi
Normal file
20
django-stubs/db/migrations/exceptions.pyi
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
from django.db.migrations.migration import Migration
|
||||
from django.db.utils import DatabaseError
|
||||
|
||||
class AmbiguityError(Exception): ...
|
||||
class BadMigrationError(Exception): ...
|
||||
class CircularDependencyError(Exception): ...
|
||||
class InconsistentMigrationHistory(Exception): ...
|
||||
class InvalidBasesError(ValueError): ...
|
||||
class IrreversibleError(RuntimeError): ...
|
||||
|
||||
class NodeNotFoundError(LookupError):
|
||||
message: str = ...
|
||||
origin: None = ...
|
||||
node: Tuple[str, str] = ...
|
||||
def __init__(self, message: str, node: Tuple[str, str], origin: Optional[Migration] = ...) -> None: ...
|
||||
|
||||
class MigrationSchemaMissing(DatabaseError): ...
|
||||
class InvalidMigrationPlan(ValueError): ...
|
||||
40
django-stubs/db/migrations/executor.pyi
Normal file
40
django-stubs/db/migrations/executor.pyi
Normal file
@@ -0,0 +1,40 @@
|
||||
from typing import Any, Callable, List, Optional, Set, Tuple, Union
|
||||
|
||||
from django.db import DefaultConnectionProxy
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.migrations.migration import Migration
|
||||
|
||||
from .loader import MigrationLoader
|
||||
from .recorder import MigrationRecorder
|
||||
from .state import ProjectState
|
||||
|
||||
class MigrationExecutor:
|
||||
connection: Any = ...
|
||||
loader: MigrationLoader = ...
|
||||
recorder: MigrationRecorder = ...
|
||||
progress_callback: Callable = ...
|
||||
def __init__(
|
||||
self,
|
||||
connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]],
|
||||
progress_callback: Optional[Callable] = ...,
|
||||
) -> None: ...
|
||||
def migration_plan(
|
||||
self, targets: Union[List[Tuple[str, Optional[str]]], Set[Tuple[str, str]]], clean_start: bool = ...
|
||||
) -> List[Tuple[Migration, bool]]: ...
|
||||
def migrate(
|
||||
self,
|
||||
targets: Optional[List[Tuple[str, Optional[str]]]],
|
||||
plan: Optional[List[Tuple[Migration, bool]]] = ...,
|
||||
state: Optional[ProjectState] = ...,
|
||||
fake: bool = ...,
|
||||
fake_initial: bool = ...,
|
||||
) -> ProjectState: ...
|
||||
def collect_sql(self, plan: List[Tuple[Migration, bool]]) -> List[str]: ...
|
||||
def apply_migration(
|
||||
self, state: ProjectState, migration: Migration, fake: bool = ..., fake_initial: bool = ...
|
||||
) -> ProjectState: ...
|
||||
def unapply_migration(self, state: ProjectState, migration: Migration, fake: bool = ...) -> ProjectState: ...
|
||||
def check_replacements(self) -> None: ...
|
||||
def detect_soft_applied(
|
||||
self, project_state: Optional[ProjectState], migration: Migration
|
||||
) -> Tuple[bool, ProjectState]: ...
|
||||
60
django-stubs/db/migrations/graph.pyi
Normal file
60
django-stubs/db/migrations/graph.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
from typing import Any, Callable, List, Optional, Tuple, Union, Set, Dict
|
||||
|
||||
from django.db.migrations.migration import Migration, SwappableTuple
|
||||
from django.db.migrations.state import ProjectState
|
||||
|
||||
RECURSION_DEPTH_WARNING: str
|
||||
|
||||
class Node:
|
||||
key: Tuple[str, str] = ...
|
||||
children: Set[Any] = ...
|
||||
parents: Set[Any] = ...
|
||||
def __init__(self, key: Tuple[str, str]) -> None: ...
|
||||
def __eq__(self, other: Tuple[str, str]) -> bool: ...
|
||||
def __lt__(self, other: Union[Tuple[str, str], Node]) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __getitem__(self, item: int) -> str: ...
|
||||
def add_child(self, child: Node) -> None: ...
|
||||
def add_parent(self, parent: Node) -> None: ...
|
||||
def ancestors(self) -> List[Tuple[str, str]]: ...
|
||||
def descendants(self) -> List[Tuple[str, str]]: ...
|
||||
|
||||
class DummyNode(Node):
|
||||
children: Set[Any]
|
||||
key: Tuple[str, str]
|
||||
parents: Set[Any]
|
||||
origin: Any = ...
|
||||
error_message: Any = ...
|
||||
def __init__(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
|
||||
__class__: Any = ...
|
||||
def promote(self) -> None: ...
|
||||
def raise_error(self) -> None: ...
|
||||
|
||||
class MigrationGraph:
|
||||
node_map: Dict[Any, Any] = ...
|
||||
nodes: Dict[Any, Any] = ...
|
||||
cached: bool = ...
|
||||
def __init__(self) -> None: ...
|
||||
def add_node(self, key: Tuple[str, str], migration: Optional[Migration]) -> None: ...
|
||||
def add_dummy_node(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
|
||||
def add_dependency(
|
||||
self,
|
||||
migration: Optional[Union[Migration, str]],
|
||||
child: Tuple[str, str],
|
||||
parent: Tuple[str, str],
|
||||
skip_validation: bool = ...,
|
||||
) -> None: ...
|
||||
def remove_replaced_nodes(self, replacement: Tuple[str, str], replaced: List[Tuple[str, str]]) -> None: ...
|
||||
def remove_replacement_node(self, replacement: Tuple[str, str], replaced: List[Tuple[str, str]]) -> None: ...
|
||||
def validate_consistency(self) -> None: ...
|
||||
def clear_cache(self) -> None: ...
|
||||
def forwards_plan(self, target: Tuple[str, str]) -> List[Tuple[str, str]]: ...
|
||||
def backwards_plan(self, target: Union[Tuple[str, str], Node]) -> List[Tuple[str, str]]: ...
|
||||
def iterative_dfs(self, start: Any, forwards: bool = ...): ...
|
||||
def root_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ...
|
||||
def leaf_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ...
|
||||
def ensure_not_cyclic(self, start: Union[Tuple[str, str], Node], get_children: Callable) -> None: ...
|
||||
def make_state(
|
||||
self, nodes: Optional[Tuple[str, str]] = ..., at_end: bool = ..., real_apps: List[str] = ...
|
||||
) -> ProjectState: ...
|
||||
def __contains__(self, node: Union[Tuple[str, str], SwappableTuple]) -> bool: ...
|
||||
37
django-stubs/db/migrations/loader.pyi
Normal file
37
django-stubs/db/migrations/loader.pyi
Normal file
@@ -0,0 +1,37 @@
|
||||
from typing import Any, Dict, Optional, Set, Tuple, Union
|
||||
|
||||
from django.db import DefaultConnectionProxy
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.migrations.migration import Migration, SwappableTuple
|
||||
from django.db.migrations.state import ProjectState
|
||||
|
||||
MIGRATIONS_MODULE_NAME: str
|
||||
|
||||
class MigrationLoader:
|
||||
connection: Any = ...
|
||||
disk_migrations: Dict[Tuple[str, str], Migration] = ...
|
||||
applied_migrations: None = ...
|
||||
ignore_no_migrations: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]],
|
||||
load: bool = ...,
|
||||
ignore_no_migrations: bool = ...,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def migrations_module(cls, app_label: str) -> Tuple[Optional[str], bool]: ...
|
||||
unmigrated_apps: Set[str] = ...
|
||||
migrated_apps: Set[str] = ...
|
||||
def load_disk(self) -> None: ...
|
||||
def get_migration(self, app_label: str, name_prefix: str) -> Migration: ...
|
||||
def get_migration_by_prefix(self, app_label: str, name_prefix: str) -> Migration: ...
|
||||
def check_key(self, key: Union[Tuple[str, str], SwappableTuple], current_app: str) -> Optional[Tuple[str, str]]: ...
|
||||
def add_internal_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ...
|
||||
def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ...
|
||||
graph: Any = ...
|
||||
replacements: Any = ...
|
||||
def build_graph(self) -> None: ...
|
||||
def check_consistent_history(self, connection: Union[DefaultConnectionProxy, DatabaseWrapper]) -> None: ...
|
||||
def detect_conflicts(self) -> Dict[str, Set[str]]: ...
|
||||
def project_state(self, nodes: Optional[Tuple[str, str]] = ..., at_end: bool = ...) -> ProjectState: ...
|
||||
30
django-stubs/db/migrations/migration.pyi
Normal file
30
django-stubs/db/migrations/migration.pyi
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import Any, Tuple, Type, List
|
||||
|
||||
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.state import ProjectState
|
||||
|
||||
class Migration:
|
||||
operations: List[Any] = ...
|
||||
dependencies: List[Any] = ...
|
||||
run_before: List[Any] = ...
|
||||
replaces: List[Any] = ...
|
||||
initial: Any = ...
|
||||
atomic: bool = ...
|
||||
name: str = ...
|
||||
app_label: str = ...
|
||||
def __init__(self, name: str, app_label: str) -> None: ...
|
||||
def __eq__(self, other: Migration) -> bool: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def mutate_state(self, project_state: ProjectState, preserve: bool = ...) -> ProjectState: ...
|
||||
def apply(
|
||||
self, project_state: ProjectState, schema_editor: DatabaseSchemaEditor, collect_sql: bool = ...
|
||||
) -> ProjectState: ...
|
||||
def unapply(
|
||||
self, project_state: ProjectState, schema_editor: DatabaseSchemaEditor, collect_sql: bool = ...
|
||||
) -> ProjectState: ...
|
||||
|
||||
class SwappableTuple(tuple):
|
||||
setting: str = ...
|
||||
def __new__(cls: Type[SwappableTuple], value: Tuple[str, str], setting: str) -> SwappableTuple: ...
|
||||
|
||||
def swappable_dependency(value: str) -> SwappableTuple: ...
|
||||
60
django-stubs/db/migrations/operations/__init__.pyi
Normal file
60
django-stubs/db/migrations/operations/__init__.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
# Stubs for django.db.migrations.operations (Python 3.6)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from .fields import (
|
||||
AddField as AddField,
|
||||
AlterField as AlterField,
|
||||
RemoveField as RemoveField,
|
||||
RenameField as RenameField,
|
||||
)
|
||||
from .models import (
|
||||
AddIndex as AddIndex,
|
||||
AlterIndexTogether as AlterIndexTogether,
|
||||
AlterModelManagers as AlterModelManagers,
|
||||
AlterModelOptions as AlterModelOptions,
|
||||
AlterModelTable as AlterModelTable,
|
||||
AlterOrderWithRespectTo as AlterOrderWithRespectTo,
|
||||
AlterUniqueTogether as AlterUniqueTogether,
|
||||
CreateModel as CreateModel,
|
||||
DeleteModel as DeleteModel,
|
||||
RemoveIndex as RemoveIndex,
|
||||
RenameModel as RenameModel,
|
||||
)
|
||||
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",
|
||||
]
|
||||
18
django-stubs/db/migrations/operations/base.pyi
Normal file
18
django-stubs/db/migrations/operations/base.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any, List, Optional, Type
|
||||
|
||||
class Operation:
|
||||
reversible: bool = ...
|
||||
reduces_to_sql: bool = ...
|
||||
atomic: bool = ...
|
||||
elidable: bool = ...
|
||||
serialization_expand_args: Any = ...
|
||||
def __new__(cls: Type[Operation], *args: Any, **kwargs: Any) -> Operation: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def describe(self): ...
|
||||
def references_model(self, name: str, app_label: str = ...) -> bool: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: str = ...) -> bool: ...
|
||||
def allow_migrate_model(self, connection_alias: Any, model: Any): ...
|
||||
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...
|
||||
77
django-stubs/db/migrations/operations/fields.pyi
Normal file
77
django-stubs/db/migrations/operations/fields.pyi
Normal file
@@ -0,0 +1,77 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.operations.base import Operation
|
||||
from django.db.migrations.state import ProjectState
|
||||
from django.db.models.fields import Field, SlugField
|
||||
|
||||
from .base import Operation
|
||||
from .utils import is_referenced_by_foreign_key
|
||||
|
||||
class FieldOperation(Operation):
|
||||
model_name: Any = ...
|
||||
name: Any = ...
|
||||
def __init__(self, model_name: str, name: str) -> None: ...
|
||||
def model_name_lower(self) -> str: ...
|
||||
def name_lower(self) -> str: ...
|
||||
def is_same_model_operation(self, operation: FieldOperation) -> bool: ...
|
||||
def is_same_field_operation(self, operation: AddField) -> bool: ...
|
||||
def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: str = ...) -> bool: ...
|
||||
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...
|
||||
|
||||
class AddField(FieldOperation):
|
||||
field: Any = ...
|
||||
preserve_default: Any = ...
|
||||
def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[bool, Field, str]]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...
|
||||
|
||||
class RemoveField(FieldOperation):
|
||||
model_name: str
|
||||
model_name_lower: str
|
||||
name: str
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
|
||||
class AlterField(FieldOperation):
|
||||
field: Any = ...
|
||||
preserve_default: Any = ...
|
||||
def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[SlugField, str]]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
def reduce(self, operation: Operation, in_between: List[AlterField], app_label: str = ...) -> bool: ...
|
||||
|
||||
class RenameField(FieldOperation):
|
||||
old_name: Any = ...
|
||||
new_name: Any = ...
|
||||
def __init__(self, model_name: str, old_name: str, new_name: str) -> None: ...
|
||||
def old_name_lower(self): ...
|
||||
def new_name_lower(self) -> str: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def describe(self): ...
|
||||
def references_field(self, model_name: str, name: str, app_label: str = ...) -> bool: ...
|
||||
def reduce(self, operation: Operation, in_between: List[Any], app_label: str = ...) -> bool: ...
|
||||
173
django-stubs/db/migrations/operations/models.pyi
Normal file
173
django-stubs/db/migrations/operations/models.pyi
Normal file
@@ -0,0 +1,173 @@
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
|
||||
|
||||
from django.contrib.postgres.fields.citext import CIText
|
||||
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.operations.base import Operation
|
||||
from django.db.migrations.state import ProjectState
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.indexes import Index
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
class ModelOperation(Operation):
|
||||
name: Any = ...
|
||||
def __init__(self, name: str) -> None: ...
|
||||
def name_lower(self) -> str: ...
|
||||
def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...
|
||||
|
||||
class CreateModel(ModelOperation):
|
||||
serialization_expand_args: Any = ...
|
||||
fields: Any = ...
|
||||
options: Any = ...
|
||||
bases: Any = ...
|
||||
managers: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
fields: List[Tuple[str, Union[CIText, Field]]],
|
||||
options: Optional[Dict[str, Any]] = ...,
|
||||
bases: Optional[Union[Tuple[Type[Any], ...], Tuple[str, ...]]] = ...,
|
||||
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[Dict[str, str], List[Tuple[str, Field]], str]]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
def references_model(self, name: str, app_label: str = ...) -> bool: ...
|
||||
def model_to_key(self, model: str) -> List[str]: ...
|
||||
def reduce(
|
||||
self, operation: Operation, in_between: List[Operation], app_label: str = ...
|
||||
) -> Union[List[CreateModel], bool]: ...
|
||||
|
||||
class DeleteModel(ModelOperation):
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
|
||||
class RenameModel(ModelOperation):
|
||||
old_name: Any = ...
|
||||
new_name: Any = ...
|
||||
def __init__(self, old_name: str, new_name: str) -> None: ...
|
||||
def old_name_lower(self) -> str: ...
|
||||
def new_name_lower(self) -> str: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def references_model(self, name: Any, app_label: Optional[Any] = ...): ...
|
||||
def describe(self): ...
|
||||
def reduce(self, operation: AlterModelTable, in_between: List[Any], app_label: str = ...) -> bool: ...
|
||||
|
||||
class AlterModelTable(ModelOperation):
|
||||
table: Any = ...
|
||||
def __init__(self, name: str, table: Optional[str]) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any): ...
|
||||
def describe(self): ...
|
||||
def reduce(self, operation: Any, in_between: Any, app_label: Optional[Any] = ...): ...
|
||||
|
||||
class ModelOptionOperation(ModelOperation):
|
||||
def reduce(self, operation: Operation, in_between: List[DeleteModel], app_label: str = ...) -> bool: ...
|
||||
|
||||
class FieldRelatedOptionOperation(ModelOptionOperation):
|
||||
def reduce(
|
||||
self, operation: Operation, in_between: List[Any], app_label: str = ...
|
||||
) -> Union[List[Operation], bool]: ...
|
||||
|
||||
class AlterUniqueTogether(FieldRelatedOptionOperation):
|
||||
option_name: str = ...
|
||||
unique_together: Any = ...
|
||||
def __init__(self, name: str, unique_together: Set[Tuple[str, ...]]) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[Set[Tuple[str, str]], str]]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def describe(self) -> str: ...
|
||||
|
||||
class AlterIndexTogether(FieldRelatedOptionOperation):
|
||||
option_name: str = ...
|
||||
index_together: Any = ...
|
||||
def __init__(self, name: str, index_together: Set[Tuple[str, str]]) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any): ...
|
||||
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def describe(self): ...
|
||||
|
||||
class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
|
||||
name: str
|
||||
order_with_respect_to: str = ...
|
||||
def __init__(self, name: str, order_with_respect_to: str) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: None = ...) -> bool: ...
|
||||
def describe(self): ...
|
||||
|
||||
class AlterModelOptions(ModelOptionOperation):
|
||||
ALTER_OPTION_KEYS: Any = ...
|
||||
options: Any = ...
|
||||
def __init__(self, name: str, options: Dict[str, str]) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def describe(self): ...
|
||||
|
||||
class AlterModelManagers(ModelOptionOperation):
|
||||
serialization_expand_args: Any = ...
|
||||
managers: Any = ...
|
||||
def __init__(self, name: Any, managers: Any) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def describe(self): ...
|
||||
|
||||
class IndexOperation(Operation):
|
||||
option_name: str = ...
|
||||
def model_name_lower(self): ...
|
||||
|
||||
class AddIndex(IndexOperation):
|
||||
model_name: str = ...
|
||||
index: django.db.models.indexes.Index = ...
|
||||
def __init__(self, model_name: str, index: Index) -> None: ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def describe(self): ...
|
||||
|
||||
class RemoveIndex(IndexOperation):
|
||||
model_name: str = ...
|
||||
name: str = ...
|
||||
def __init__(self, model_name: str, name: str) -> None: ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def describe(self): ...
|
||||
74
django-stubs/db/migrations/operations/special.pyi
Normal file
74
django-stubs/db/migrations/operations/special.pyi
Normal file
@@ -0,0 +1,74 @@
|
||||
from typing import Any, Callable, List, Optional
|
||||
|
||||
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.operations.models import CreateModel
|
||||
from django.db.migrations.state import ProjectState, StateApps
|
||||
|
||||
from .base import Operation
|
||||
|
||||
class SeparateDatabaseAndState(Operation):
|
||||
serialization_expand_args: Any = ...
|
||||
database_operations: Any = ...
|
||||
state_operations: Any = ...
|
||||
def __init__(self, database_operations: List[Any] = ..., state_operations: List[CreateModel] = ...) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self): ...
|
||||
|
||||
class RunSQL(Operation):
|
||||
noop: str = ...
|
||||
sql: Any = ...
|
||||
reverse_sql: Any = ...
|
||||
state_operations: Any = ...
|
||||
hints: Any = ...
|
||||
elidable: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
sql: Any,
|
||||
reverse_sql: Optional[Any] = ...,
|
||||
state_operations: Optional[Any] = ...,
|
||||
hints: Optional[Any] = ...,
|
||||
elidable: bool = ...,
|
||||
) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
@property
|
||||
def reversible(self): ...
|
||||
def state_forwards(self, app_label: Any, state: Any) -> None: ...
|
||||
def database_forwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
|
||||
def describe(self): ...
|
||||
|
||||
class RunPython(Operation):
|
||||
reduces_to_sql: bool = ...
|
||||
atomic: Any = ...
|
||||
code: Any = ...
|
||||
reverse_code: Any = ...
|
||||
hints: Any = ...
|
||||
elidable: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
code: Callable,
|
||||
reverse_code: Optional[Callable] = ...,
|
||||
atomic: Optional[bool] = ...,
|
||||
hints: None = ...,
|
||||
elidable: bool = ...,
|
||||
) -> None: ...
|
||||
def deconstruct(self): ...
|
||||
@property
|
||||
def reversible(self) -> bool: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
def database_forwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self, app_label: str, schema_editor: DatabaseSchemaEditor, from_state: ProjectState, to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self): ...
|
||||
@staticmethod
|
||||
def noop(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ...
|
||||
6
django-stubs/db/migrations/operations/utils.pyi
Normal file
6
django-stubs/db/migrations/operations/utils.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.db.migrations.state import ProjectState
|
||||
from django.db.models.fields import Field
|
||||
|
||||
def is_referenced_by_foreign_key(state: ProjectState, model_name_lower: str, field: Field, field_name: str) -> bool: ...
|
||||
7
django-stubs/db/migrations/optimizer.pyi
Normal file
7
django-stubs/db/migrations/optimizer.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
||||
class MigrationOptimizer:
|
||||
def optimize(self, operations: List[Operation], app_label: str = ...) -> List[Operation]: ...
|
||||
def optimize_inner(self, operations: List[Operation], app_label: str = ...) -> List[Operation]: ...
|
||||
43
django-stubs/db/migrations/questioner.pyi
Normal file
43
django-stubs/db/migrations/questioner.pyi
Normal file
@@ -0,0 +1,43 @@
|
||||
from typing import Any, Dict, Optional, Set
|
||||
|
||||
from django.db.migrations.state import ModelState
|
||||
from django.db.models.fields import Field
|
||||
|
||||
from .loader import MigrationLoader
|
||||
|
||||
class MigrationQuestioner:
|
||||
defaults: Dict[Any, Any] = ...
|
||||
specified_apps: Set[Any] = ...
|
||||
dry_run: None = ...
|
||||
def __init__(
|
||||
self,
|
||||
defaults: Optional[Dict[str, bool]] = ...,
|
||||
specified_apps: Optional[Set[str]] = ...,
|
||||
dry_run: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
def ask_initial(self, app_label: str) -> bool: ...
|
||||
def ask_not_null_addition(self, field_name: str, model_name: str) -> None: ...
|
||||
def ask_not_null_alteration(self, field_name: Any, model_name: Any): ...
|
||||
def ask_rename(self, model_name: str, old_name: str, new_name: str, field_instance: Field) -> bool: ...
|
||||
def ask_rename_model(self, old_model_state: ModelState, new_model_state: ModelState) -> bool: ...
|
||||
def ask_merge(self, app_label: str) -> bool: ...
|
||||
def ask_auto_now_add_addition(self, field_name: str, model_name: str) -> None: ...
|
||||
|
||||
class InteractiveMigrationQuestioner(MigrationQuestioner):
|
||||
defaults: Dict[Any, Any]
|
||||
dry_run: bool
|
||||
specified_apps: Set[str]
|
||||
def ask_not_null_addition(self, field_name: str, model_name: str) -> None: ...
|
||||
def ask_not_null_alteration(self, field_name: Any, model_name: Any): ...
|
||||
def ask_rename(self, model_name: Any, old_name: Any, new_name: Any, field_instance: Any): ...
|
||||
def ask_rename_model(self, old_model_state: Any, new_model_state: Any): ...
|
||||
def ask_merge(self, app_label: str) -> bool: ...
|
||||
def ask_auto_now_add_addition(self, field_name: str, model_name: str) -> int: ...
|
||||
|
||||
class NonInteractiveMigrationQuestioner(MigrationQuestioner):
|
||||
defaults: Dict[Any, Any]
|
||||
dry_run: bool
|
||||
specified_apps: Set[str]
|
||||
def ask_not_null_addition(self, field_name: Any, model_name: Any) -> None: ...
|
||||
def ask_not_null_alteration(self, field_name: Any, model_name: Any): ...
|
||||
def ask_auto_now_add_addition(self, field_name: Any, model_name: Any) -> None: ...
|
||||
27
django-stubs/db/migrations/recorder.pyi
Normal file
27
django-stubs/db/migrations/recorder.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import Any, Optional, Set, Tuple, Union
|
||||
|
||||
from django.db import DefaultConnectionProxy, models
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from .exceptions import MigrationSchemaMissing
|
||||
|
||||
class MigrationRecorder:
|
||||
class Migration(models.Model):
|
||||
app: Any = ...
|
||||
name: Any = ...
|
||||
applied: Any = ...
|
||||
class Meta:
|
||||
apps: Any = ...
|
||||
app_label: str = ...
|
||||
db_table: str = ...
|
||||
connection: Any = ...
|
||||
def __init__(self, connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]]) -> None: ...
|
||||
@property
|
||||
def migration_qs(self) -> QuerySet: ...
|
||||
def has_table(self) -> bool: ...
|
||||
def ensure_schema(self) -> None: ...
|
||||
def applied_migrations(self) -> Set[Tuple[str, str]]: ...
|
||||
def record_applied(self, app: str, name: str) -> None: ...
|
||||
def record_unapplied(self, app: str, name: str) -> None: ...
|
||||
def flush(self) -> None: ...
|
||||
88
django-stubs/db/migrations/serializer.pyi
Normal file
88
django-stubs/db/migrations/serializer.pyi
Normal file
@@ -0,0 +1,88 @@
|
||||
from typing import Any, Callable, Dict, List, Set, Tuple, Union
|
||||
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class BaseSerializer:
|
||||
value: Any = ...
|
||||
def __init__(self, value: Any) -> None: ...
|
||||
def serialize(self) -> None: ...
|
||||
|
||||
class BaseSequenceSerializer(BaseSerializer):
|
||||
def serialize(self) -> Tuple[str, Set[str]]: ...
|
||||
|
||||
class BaseSimpleSerializer(BaseSerializer):
|
||||
value: str
|
||||
def serialize(self) -> Tuple[str, Set[Any]]: ...
|
||||
|
||||
class DatetimeSerializer(BaseSerializer):
|
||||
value: Any = ...
|
||||
def serialize(self): ...
|
||||
|
||||
class DateSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class DecimalSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class DeconstructableSerializer(BaseSerializer):
|
||||
@staticmethod
|
||||
def serialize_deconstructed(
|
||||
path: str, args: List[Any], kwargs: Dict[str, Union[Callable, int, str]]
|
||||
) -> Tuple[str, Set[str]]: ...
|
||||
def serialize(self): ...
|
||||
|
||||
class DictionarySerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class EnumSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class FloatSerializer(BaseSimpleSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class FrozensetSerializer(BaseSequenceSerializer): ...
|
||||
|
||||
class FunctionTypeSerializer(BaseSerializer):
|
||||
value: Callable
|
||||
def serialize(self) -> Tuple[str, Set[str]]: ...
|
||||
|
||||
class FunctoolsPartialSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class IterableSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class ModelFieldSerializer(DeconstructableSerializer):
|
||||
value: Field
|
||||
def serialize(self) -> Tuple[str, Set[str]]: ...
|
||||
|
||||
class ModelManagerSerializer(DeconstructableSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class OperationSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class RegexSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class SequenceSerializer(BaseSequenceSerializer): ...
|
||||
class SetSerializer(BaseSequenceSerializer): ...
|
||||
|
||||
class SettingsReferenceSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class TimedeltaSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class TimeSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class TupleSerializer(BaseSequenceSerializer): ...
|
||||
|
||||
class TypeSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
class UUIDSerializer(BaseSerializer):
|
||||
def serialize(self): ...
|
||||
|
||||
def serializer_factory(value: Any) -> BaseSerializer: ...
|
||||
86
django-stubs/db/migrations/state.pyi
Normal file
86
django-stubs/db/migrations/state.pyi
Normal file
@@ -0,0 +1,86 @@
|
||||
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, DefaultDict
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.contrib.postgres.fields.citext import CIText
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.indexes import Index
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
class AppConfigStub:
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: None
|
||||
name: str
|
||||
verbose_name: str
|
||||
def __init__(self, label: str) -> None: ...
|
||||
def import_models(self) -> None: ...
|
||||
|
||||
class ModelState:
|
||||
def __init__(
|
||||
self,
|
||||
app_label: str,
|
||||
name: str,
|
||||
fields: List[Tuple[str, Union[CIText, Field]]],
|
||||
options: Optional[
|
||||
Union[
|
||||
Dict[str, List[Index]],
|
||||
Dict[str, List[str]],
|
||||
Dict[str, Set[Tuple[str, str]]],
|
||||
Dict[str, Tuple[str]],
|
||||
Dict[str, bool],
|
||||
Dict[str, str],
|
||||
]
|
||||
] = ...,
|
||||
bases: Optional[Tuple[Type[Model]]] = ...,
|
||||
managers: Optional[List[Tuple[str, Manager]]] = ...,
|
||||
) -> None: ...
|
||||
def clone(self) -> ModelState: ...
|
||||
def construct_managers(self) -> Iterator[Tuple[str, Manager]]: ...
|
||||
@classmethod
|
||||
def from_model(cls, model: Type[Model], exclude_rels: bool = ...) -> ModelState: ...
|
||||
def get_field_by_name(self, name: str) -> Field: ...
|
||||
@cached_property
|
||||
def name_lower(self) -> str: ...
|
||||
def render(self, apps: StateApps) -> Any: ...
|
||||
|
||||
class ProjectState:
|
||||
is_delayed: bool
|
||||
models: Dict[Any, Any]
|
||||
real_apps: List[str]
|
||||
def __init__(
|
||||
self, models: Optional[Dict[Tuple[str, str], ModelState]] = ..., real_apps: Optional[List[str]] = ...
|
||||
) -> None: ...
|
||||
def add_model(self, model_state: ModelState) -> None: ...
|
||||
@cached_property
|
||||
def apps(self) -> StateApps: ...
|
||||
def clear_delayed_apps_cache(self) -> None: ...
|
||||
def clone(self) -> ProjectState: ...
|
||||
@property
|
||||
def concrete_apps(self) -> StateApps: ...
|
||||
@classmethod
|
||||
def from_apps(cls, apps: Apps) -> ProjectState: ...
|
||||
def reload_model(self, app_label: str, model_name: str, delay: bool = ...) -> None: ...
|
||||
def reload_models(self, models: List[Any], delay: bool = ...) -> None: ...
|
||||
def remove_model(self, app_label: str, model_name: str) -> None: ...
|
||||
|
||||
class StateApps(Apps):
|
||||
all_models: DefaultDict
|
||||
app_configs: Dict
|
||||
apps_ready: bool
|
||||
loading: bool
|
||||
models_ready: bool
|
||||
ready: bool
|
||||
real_models: List[ModelState]
|
||||
stored_app_configs: List[Any]
|
||||
def __init__(
|
||||
self, real_apps: List[str], models: Dict[Tuple[str, str], ModelState], ignore_swappable: bool = ...
|
||||
) -> None: ...
|
||||
def bulk_update(self) -> Iterator[None]: ...
|
||||
def clone(self) -> StateApps: ...
|
||||
def render_multiple(self, model_states: List[ModelState]) -> None: ...
|
||||
def unregister_model(self, app_label: str, model_name: str) -> None: ...
|
||||
8
django-stubs/db/migrations/topological_sort.pyi
Normal file
8
django-stubs/db/migrations/topological_sort.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from typing import Any, Dict, Iterator, List, Optional, Set
|
||||
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
||||
def topological_sort_as_sets(dependency_graph: Dict[Operation, Set[Operation]]) -> Iterator[Set[Operation]]: ...
|
||||
def stable_topological_sort(
|
||||
l: List[Operation], dependency_graph: Dict[Operation, Set[Operation]]
|
||||
) -> List[Operation]: ...
|
||||
13
django-stubs/db/migrations/utils.pyi
Normal file
13
django-stubs/db/migrations/utils.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
COMPILED_REGEX_TYPE: Any
|
||||
|
||||
class RegexObject:
|
||||
pattern: str = ...
|
||||
flags: int = ...
|
||||
def __init__(self, obj: SimpleLazyObject) -> None: ...
|
||||
def __eq__(self, other: RegexObject) -> bool: ...
|
||||
|
||||
def get_migration_name_timestamp() -> str: ...
|
||||
38
django-stubs/db/migrations/writer.pyi
Normal file
38
django-stubs/db/migrations/writer.pyi
Normal file
@@ -0,0 +1,38 @@
|
||||
from typing import Any, Optional, Set, Tuple, Type, List
|
||||
|
||||
from django.db.migrations.migration import Migration
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
||||
from django.db.migrations.operations.models import CreateModel
|
||||
|
||||
class SettingsReference(str):
|
||||
def __new__(self: Type[SettingsReference], value: str, setting_name: str) -> SettingsReference: ...
|
||||
setting_name: str = ...
|
||||
def __init__(self, value: str, setting_name: str) -> None: ...
|
||||
|
||||
class OperationWriter:
|
||||
operation: CreateModel = ...
|
||||
buff: List[Any] = ...
|
||||
indentation: int = ...
|
||||
def __init__(self, operation: Operation, indentation: int = ...) -> None: ...
|
||||
def serialize(self) -> Tuple[str, Set[str]]: ...
|
||||
def indent(self) -> None: ...
|
||||
def unindent(self) -> None: ...
|
||||
def feed(self, line: str) -> None: ...
|
||||
def render(self) -> str: ...
|
||||
|
||||
class MigrationWriter:
|
||||
migration: Migration = ...
|
||||
needs_manual_porting: bool = ...
|
||||
def __init__(self, migration: Migration) -> None: ...
|
||||
def as_string(self) -> str: ...
|
||||
@property
|
||||
def basedir(self) -> str: ...
|
||||
@property
|
||||
def filename(self) -> str: ...
|
||||
@property
|
||||
def path(self) -> str: ...
|
||||
@classmethod
|
||||
def serialize(cls, value: Any) -> Tuple[str, Set[str]]: ...
|
||||
|
||||
MIGRATION_TEMPLATE: str
|
||||
@@ -3,9 +3,12 @@ from .base import Model as Model
|
||||
from .fields import (
|
||||
AutoField as AutoField,
|
||||
IntegerField as IntegerField,
|
||||
PositiveIntegerField as PositiveIntegerField,
|
||||
PositiveSmallIntegerField as PositiveSmallIntegerField,
|
||||
SmallIntegerField as SmallIntegerField,
|
||||
BigIntegerField as BigIntegerField,
|
||||
CharField as CharField,
|
||||
EmailField as EmailField,
|
||||
Field as Field,
|
||||
SlugField as SlugField,
|
||||
TextField as TextField,
|
||||
|
||||
@@ -9,6 +9,11 @@ class Field(RegisterLookupMixin):
|
||||
class IntegerField(Field):
|
||||
def __get__(self, instance, owner) -> int: ...
|
||||
|
||||
class PositiveIntegerRelDbTypeMixin:
|
||||
def rel_db_type(self, connection: Any): ...
|
||||
|
||||
class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
||||
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
|
||||
class SmallIntegerField(IntegerField): ...
|
||||
class BigIntegerField(IntegerField): ...
|
||||
|
||||
@@ -21,6 +26,7 @@ class CharField(Field):
|
||||
def __get__(self, instance, owner) -> str: ...
|
||||
|
||||
class SlugField(CharField): ...
|
||||
class EmailField(CharField): ...
|
||||
|
||||
class TextField(Field):
|
||||
def __set__(self, instance, value: str) -> None: ...
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
# Stubs for django.http.response (Python 3.5)
|
||||
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
from json import JSONEncoder
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, overload, Tuple, Type, Union
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, overload, Tuple, Type, Union, Callable
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.cookie import SimpleCookie
|
||||
import six
|
||||
from django.template import Context, Template
|
||||
from django.test import Client
|
||||
|
||||
from django.urls import ResolverMatch
|
||||
|
||||
class BadHeaderError(ValueError): ...
|
||||
|
||||
@@ -55,15 +61,37 @@ class HttpResponseBase(six.Iterator):
|
||||
def writelines(self, lines: Iterable[object]) -> None: ...
|
||||
|
||||
class HttpResponse(HttpResponseBase):
|
||||
streaming = ... # type: bool
|
||||
def __init__(self, content: object = b"", *args: Any, **kwargs: Any) -> None: ...
|
||||
client: Client
|
||||
closed: bool
|
||||
context: Optional[Context]
|
||||
cookies: cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: Callable[[], Dict]
|
||||
redirect_chain: List[Tuple[str, int]]
|
||||
request: Dict[str, Any]
|
||||
resolver_match: ResolverMatch
|
||||
sameorigin: bool
|
||||
status_code: int
|
||||
templates: List[Template]
|
||||
test_server_port: str
|
||||
test_was_secure_request: bool
|
||||
wsgi_request: WSGIRequest
|
||||
xframe_options_exempt: bool
|
||||
streaming: bool = ...
|
||||
def __init__(self, content: object = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def serialize(self) -> bytes: ...
|
||||
@property
|
||||
def content(self) -> bytes: ...
|
||||
@content.setter
|
||||
def content(self, value: Any) -> None: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def write(self, content: Union[bytes, str]) -> None: ...
|
||||
def tell(self) -> int: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
def writable(self) -> bool: ...
|
||||
def writelines(self, lines: List[str]) -> None: ...
|
||||
@property
|
||||
def url(self) -> str: ...
|
||||
|
||||
class StreamingHttpResponse(HttpResponseBase):
|
||||
def __init__(self, streaming_content: Iterable[bytes] = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
@@ -76,7 +104,22 @@ class StreamingHttpResponse(HttpResponseBase):
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def getvalue(self) -> bytes: ...
|
||||
|
||||
class FileResponse(StreamingHttpResponse): ...
|
||||
class FileResponse(StreamingHttpResponse):
|
||||
client: Client
|
||||
closed: bool
|
||||
context: None
|
||||
cookies: cookies.SimpleCookie
|
||||
file_to_stream: Optional[BytesIO]
|
||||
json: Callable[[], Dict]
|
||||
request: Dict[str, str]
|
||||
resolver_match: ResolverMatch
|
||||
templates: List[Any]
|
||||
wsgi_request: WSGIRequest
|
||||
block_size: int = ...
|
||||
as_attachment: bool = ...
|
||||
filename: str = ...
|
||||
def __init__(self, *args: Any, as_attachment: bool = ..., filename: str = ..., **kwargs: Any) -> None: ...
|
||||
def set_headers(self, filelike: BytesIO) -> None: ...
|
||||
|
||||
class HttpResponseRedirectBase(HttpResponse):
|
||||
allowed_schemes = ... # type: List[str]
|
||||
|
||||
3
reformat.xsh
Executable file
3
reformat.xsh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/local/bin/xonsh
|
||||
|
||||
black --line-length=120 django-stubs/ django-stubs-generated/
|
||||
13
setup.py
13
setup.py
@@ -1,16 +1,5 @@
|
||||
import os
|
||||
from distutils.core import setup
|
||||
|
||||
|
||||
def find_stubs(package):
|
||||
stubs = []
|
||||
for root, dirs, files in os.walk(package):
|
||||
for file in files:
|
||||
path = os.path.join(root, file).replace(package + os.sep, '', 1)
|
||||
stubs.append(path)
|
||||
return {package: stubs}
|
||||
|
||||
|
||||
setup(
|
||||
name="django-stubs",
|
||||
url="https://github.com/mkurnikov/django-stubs.git",
|
||||
@@ -19,7 +8,7 @@ setup(
|
||||
version="0.1.0",
|
||||
license='BSD',
|
||||
install_requires=[
|
||||
'Django>=2.1.1',
|
||||
'Django',
|
||||
'mypy @ git+https://github.com/python/mypy.git#egg=mypy-0.660+dev.01c268644d1d22506442df4e21b39c04710b7e8b'
|
||||
],
|
||||
packages=['mypy_django_plugin']
|
||||
|
||||
Reference in New Issue
Block a user