mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 00:37:11 +08:00
initial commit
This commit is contained in:
22
django/db/migrations/operations/base.pyi
Normal file
22
django/db/migrations/operations/base.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
from django.db.migrations.operations.models import CreateModel
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class Operation:
|
||||
@staticmethod
|
||||
def __new__(cls: Any, *args, **kwargs) -> Operation: ...
|
||||
def _get_model_tuple(self, remote_model: str, app_label: str, model_name: str) -> Tuple[str, str]: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: Any,
|
||||
app_label: Optional[str] = ...
|
||||
) -> Union[bool, List[CreateModel]]: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: str = ...) -> bool: ...
|
||||
def references_model(self, name: str, app_label: str = ...) -> bool: ...
|
||||
141
django/db/migrations/operations/fields.pyi
Normal file
141
django/db/migrations/operations/fields.pyi
Normal file
@@ -0,0 +1,141 @@
|
||||
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.operations.base import Operation
|
||||
from django.db.migrations.operations.models import (
|
||||
AlterUniqueTogether,
|
||||
DeleteModel,
|
||||
)
|
||||
from django.db.migrations.state import ProjectState
|
||||
from django.db.models.fields import (
|
||||
CharField,
|
||||
Field,
|
||||
IntegerField,
|
||||
SlugField,
|
||||
)
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class AddField:
|
||||
def __init__(
|
||||
self,
|
||||
model_name: str,
|
||||
name: str,
|
||||
field: Field,
|
||||
preserve_default: bool = ...
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def describe(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: List[AddField],
|
||||
app_label: Optional[str] = ...
|
||||
) -> Union[bool, List[AddField]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class AlterField:
|
||||
def __init__(
|
||||
self,
|
||||
model_name: str,
|
||||
name: str,
|
||||
field: Field,
|
||||
preserve_default: bool = ...
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(
|
||||
self
|
||||
) -> Union[Tuple[str, List[Any], Dict[str, Union[str, SlugField]]], Tuple[str, List[Any], Dict[str, Union[str, CharField]]], Tuple[str, List[Any], Dict[str, Union[str, IntegerField]]]]: ...
|
||||
def describe(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Union[DeleteModel, AlterField, AlterUniqueTogether],
|
||||
in_between: List[Any],
|
||||
app_label: str = ...
|
||||
) -> bool: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class FieldOperation:
|
||||
def __init__(self, model_name: str, name: str) -> None: ...
|
||||
def is_same_field_operation(self, operation: FieldOperation) -> bool: ...
|
||||
def is_same_model_operation(self, operation: FieldOperation) -> bool: ...
|
||||
@cached_property
|
||||
def model_name_lower(self) -> str: ...
|
||||
@cached_property
|
||||
def name_lower(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: Any,
|
||||
app_label: str = ...
|
||||
) -> bool: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
|
||||
|
||||
class RemoveField:
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
def describe(self) -> str: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class RenameField:
|
||||
def __init__(self, model_name: str, old_name: str, new_name: str) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
@cached_property
|
||||
def old_name_lower(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Union[FieldOperation, AlterUniqueTogether],
|
||||
in_between: List[Any],
|
||||
app_label: Optional[str] = ...
|
||||
) -> Union[bool, List[RenameField]]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
258
django/db/migrations/operations/models.pyi
Normal file
258
django/db/migrations/operations/models.pyi
Normal file
@@ -0,0 +1,258 @@
|
||||
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.indexes import Index
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def _check_for_duplicates(arg_name: str, objs: Iterator[Any]) -> None: ...
|
||||
|
||||
|
||||
class AddIndex:
|
||||
def __init__(self, model_name: str, index: Index) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class AlterIndexTogether:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
index_together: Optional[Union[List[List[str]], List[Tuple[str, str]], Set[Tuple[str, str]]]]
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[str, Set[Tuple[str, str]]]]]: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: None = ...) -> bool: ...
|
||||
|
||||
|
||||
class AlterModelManagers:
|
||||
def __init__(self, name: str, managers: List[Any]) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
|
||||
|
||||
class AlterModelOptions:
|
||||
def __init__(self, name: str, options: Dict[str, Union[List[Tuple[str, str]], str]]) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[str, Dict[str, List[Tuple[str, str]]]]]]: ...
|
||||
|
||||
|
||||
class AlterModelTable:
|
||||
def __init__(self, name: str, table: str) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
def describe(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: DeleteModel,
|
||||
in_between: List[Any],
|
||||
app_label: None = ...
|
||||
) -> List[DeleteModel]: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class AlterOrderWithRespectTo:
|
||||
def __init__(self, name: str, order_with_respect_to: str) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
def describe(self) -> str: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: None = ...) -> bool: ...
|
||||
|
||||
|
||||
class AlterUniqueTogether:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
unique_together: Optional[Union[List[List[str]], Set[Tuple[str, str]], List[Tuple[str, str]]]]
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, Union[str, Set[Tuple[str, str]]]]]: ...
|
||||
def describe(self) -> str: ...
|
||||
def references_field(self, model_name: str, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class CreateModel:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
fields: Any,
|
||||
options: Any = ...,
|
||||
bases: Any = ...,
|
||||
managers: Any = ...
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def describe(self) -> str: ...
|
||||
def model_to_key(self, model: str) -> List[str]: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: Any,
|
||||
app_label: Optional[str] = ...
|
||||
) -> Union[bool, List[CreateModel]]: ...
|
||||
def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class DeleteModel:
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
def describe(self) -> str: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class FieldRelatedOptionOperation:
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: List[DeleteModel],
|
||||
app_label: Optional[str] = ...
|
||||
) -> Any: ...
|
||||
|
||||
|
||||
class IndexOperation:
|
||||
@cached_property
|
||||
def model_name_lower(self) -> str: ...
|
||||
|
||||
|
||||
class ModelOperation:
|
||||
def __init__(self, name: str) -> None: ...
|
||||
@cached_property
|
||||
def name_lower(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: Any,
|
||||
app_label: Optional[str] = ...
|
||||
) -> bool: ...
|
||||
def references_model(self, name: str, app_label: Optional[str] = ...) -> bool: ...
|
||||
|
||||
|
||||
class ModelOptionOperation:
|
||||
def reduce(
|
||||
self,
|
||||
operation: Operation,
|
||||
in_between: List[DeleteModel],
|
||||
app_label: Optional[str] = ...
|
||||
) -> Union[bool, List[AlterUniqueTogether]]: ...
|
||||
|
||||
|
||||
class RemoveIndex:
|
||||
def __init__(self, model_name: str, name: str) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class RenameModel:
|
||||
def __init__(self, old_name: str, new_name: str) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def deconstruct(self) -> Tuple[str, List[Any], Dict[str, str]]: ...
|
||||
@cached_property
|
||||
def new_name_lower(self) -> str: ...
|
||||
@cached_property
|
||||
def old_name_lower(self) -> str: ...
|
||||
def reduce(
|
||||
self,
|
||||
operation: AlterModelTable,
|
||||
in_between: List[Any],
|
||||
app_label: str = ...
|
||||
) -> bool: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
89
django/db/migrations/operations/special.pyi
Normal file
89
django/db/migrations/operations/special.pyi
Normal file
@@ -0,0 +1,89 @@
|
||||
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.operations.fields import AddField
|
||||
from django.db.migrations.operations.models import (
|
||||
CreateModel,
|
||||
ModelOperation,
|
||||
)
|
||||
from django.db.migrations.state import (
|
||||
ProjectState,
|
||||
StateApps,
|
||||
)
|
||||
from typing import (
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class RunPython:
|
||||
def __init__(
|
||||
self,
|
||||
code: Union[str, Callable],
|
||||
reverse_code: Optional[Callable] = ...,
|
||||
atomic: None = ...,
|
||||
hints: Optional[Dict[str, str]] = ...,
|
||||
elidable: bool = ...
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def describe(self) -> str: ...
|
||||
@staticmethod
|
||||
def noop(
|
||||
apps: StateApps,
|
||||
schema_editor: DatabaseSchemaEditor
|
||||
) -> None: ...
|
||||
@property
|
||||
def reversible(self) -> bool: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
|
||||
|
||||
class RunSQL:
|
||||
def _run_sql(
|
||||
self,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
sqls: Union[str, List[str]]
|
||||
) -> None: ...
|
||||
def database_backwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class SeparateDatabaseAndState:
|
||||
def __init__(
|
||||
self,
|
||||
database_operations: List[ModelOperation] = ...,
|
||||
state_operations: Union[List[AddField], List[CreateModel], List[ModelOperation]] = ...
|
||||
) -> None: ...
|
||||
def database_forwards(
|
||||
self,
|
||||
app_label: str,
|
||||
schema_editor: DatabaseSchemaEditor,
|
||||
from_state: ProjectState,
|
||||
to_state: ProjectState
|
||||
) -> None: ...
|
||||
def state_forwards(self, app_label: str, state: ProjectState) -> None: ...
|
||||
10
django/db/migrations/operations/utils.pyi
Normal file
10
django/db/migrations/operations/utils.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
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: ...
|
||||
Reference in New Issue
Block a user