From c22e86377d1b298b9c48cf2f717866448f6200b7 Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Fri, 21 Dec 2018 01:17:17 +0300 Subject: [PATCH] move django.core stubs --- .../db/migrations/__init__.pyi | 6 - .../db/migrations/autodetector.pyi | 69 ------- .../db/migrations/exceptions.pyi | 20 -- .../db/migrations/executor.pyi | 42 ----- .../db/migrations/graph.pyi | 62 ------- .../db/migrations/loader.pyi | 39 ---- .../db/migrations/migration.pyi | 30 --- .../db/migrations/operations/__init__.pyi | 60 ------ .../db/migrations/operations/base.pyi | 18 -- .../db/migrations/operations/fields.pyi | 77 -------- .../db/migrations/operations/models.pyi | 173 ------------------ .../db/migrations/operations/special.pyi | 74 -------- .../db/migrations/operations/utils.pyi | 6 - .../db/migrations/optimizer.pyi | 7 - .../db/migrations/questioner.pyi | 43 ----- .../db/migrations/recorder.pyi | 27 --- .../db/migrations/serializer.pyi | 86 --------- .../db/migrations/state.pyi | 84 --------- .../db/migrations/topological_sort.pyi | 8 - .../db/migrations/utils.pyi | 13 -- .../db/migrations/writer.pyi | 36 ---- django-stubs-generated/db/models/query.pyi | 29 ++- django-stubs/core/cache/__init__.pyi | 21 +++ django-stubs/core/cache/backends/__init__.pyi | 0 django-stubs/core/cache/backends/base.pyi | 47 +++++ django-stubs/core/cache/backends/db.pyi | 39 ++++ django-stubs/core/cache/backends/dummy.pyi | 19 ++ .../core/cache/backends/filebased.pyi | 22 +++ django-stubs/core/cache/backends/locmem.pyi | 26 +++ django-stubs/core/cache/utils.pyi | 5 + django-stubs/core/checks/__init__.pyi | 0 django-stubs/core/checks/caches.pyi | 7 + django-stubs/core/checks/database.pyi | 3 + django-stubs/core/checks/messages.pyi | 45 +++++ django-stubs/core/checks/model_checks.pyi | 6 + django-stubs/core/checks/registry.pyi | 35 ++++ .../core/checks/security/__init__.pyi | 0 django-stubs/core/checks/security/base.pyi | 31 ++++ django-stubs/core/checks/security/csrf.pyi | 9 + .../core/checks/security/sessions.pyi | 18 ++ django-stubs/core/checks/templates.pyi | 9 + django-stubs/core/checks/urls.pyi | 11 ++ django-stubs/core/exceptions.pyi | 58 ++++++ django-stubs/core/files/__init__.pyi | 2 +- django-stubs/core/files/images.pyi | 15 ++ django-stubs/core/files/locks.pyi | 17 ++ django-stubs/core/files/move.pyi | 3 + django-stubs/core/files/storage.pyi | 51 ++++++ django-stubs/core/handlers/__init__.pyi | 0 django-stubs/core/handlers/base.pyi | 13 ++ django-stubs/core/handlers/exception.pyi | 12 ++ django-stubs/core/handlers/wsgi.pyi | 52 ++++++ django-stubs/core/mail/__init__.pyi | 47 +++++ django-stubs/core/mail/message.pyi | 121 ++++++++++++ django-stubs/core/mail/utils.pyi | 6 + django-stubs/core/management/__init__.pyi | 20 ++ django-stubs/core/management/base.pyi | 92 ++++++++++ django-stubs/core/management/color.pyi | 7 + django-stubs/core/management/sql.pyi | 9 + django-stubs/core/management/templates.pyi | 20 ++ django-stubs/core/management/utils.pyi | 10 + django-stubs/core/paginator.pyi | 52 ++++++ django-stubs/core/serializers/__init__.pyi | 30 +++ django-stubs/core/serializers/base.pyi | 84 +++++++++ django-stubs/core/serializers/json.pyi | 33 ++++ django-stubs/core/serializers/python.pyi | 40 ++++ django-stubs/core/servers/__init__.pyi | 0 django-stubs/core/servers/basehttp.pyi | 37 ++++ django-stubs/core/signing.pyi | 48 +++++ django-stubs/core/validators.pyi | 144 +++++++++++++++ django-stubs/core/wsgi.pyi | 3 + .../db/migrations/operations/models.pyi | 2 +- django-stubs/db/migrations/recorder.pyi | 8 +- django-stubs/db/models/__init__.pyi | 1 + django-stubs/db/models/fields/__init__.pyi | 6 +- django-stubs/db/models/query.pyi | 30 ++- django-stubs/http/response.pyi | 6 +- 77 files changed, 1420 insertions(+), 1021 deletions(-) delete mode 100644 django-stubs-generated/db/migrations/__init__.pyi delete mode 100644 django-stubs-generated/db/migrations/autodetector.pyi delete mode 100644 django-stubs-generated/db/migrations/exceptions.pyi delete mode 100644 django-stubs-generated/db/migrations/executor.pyi delete mode 100644 django-stubs-generated/db/migrations/graph.pyi delete mode 100644 django-stubs-generated/db/migrations/loader.pyi delete mode 100644 django-stubs-generated/db/migrations/migration.pyi delete mode 100644 django-stubs-generated/db/migrations/operations/__init__.pyi delete mode 100644 django-stubs-generated/db/migrations/operations/base.pyi delete mode 100644 django-stubs-generated/db/migrations/operations/fields.pyi delete mode 100644 django-stubs-generated/db/migrations/operations/models.pyi delete mode 100644 django-stubs-generated/db/migrations/operations/special.pyi delete mode 100644 django-stubs-generated/db/migrations/operations/utils.pyi delete mode 100644 django-stubs-generated/db/migrations/optimizer.pyi delete mode 100644 django-stubs-generated/db/migrations/questioner.pyi delete mode 100644 django-stubs-generated/db/migrations/recorder.pyi delete mode 100644 django-stubs-generated/db/migrations/serializer.pyi delete mode 100644 django-stubs-generated/db/migrations/state.pyi delete mode 100644 django-stubs-generated/db/migrations/topological_sort.pyi delete mode 100644 django-stubs-generated/db/migrations/utils.pyi delete mode 100644 django-stubs-generated/db/migrations/writer.pyi create mode 100644 django-stubs/core/cache/__init__.pyi create mode 100644 django-stubs/core/cache/backends/__init__.pyi create mode 100644 django-stubs/core/cache/backends/base.pyi create mode 100644 django-stubs/core/cache/backends/db.pyi create mode 100644 django-stubs/core/cache/backends/dummy.pyi create mode 100644 django-stubs/core/cache/backends/filebased.pyi create mode 100644 django-stubs/core/cache/backends/locmem.pyi create mode 100644 django-stubs/core/cache/utils.pyi create mode 100644 django-stubs/core/checks/__init__.pyi create mode 100644 django-stubs/core/checks/caches.pyi create mode 100644 django-stubs/core/checks/database.pyi create mode 100644 django-stubs/core/checks/messages.pyi create mode 100644 django-stubs/core/checks/model_checks.pyi create mode 100644 django-stubs/core/checks/registry.pyi create mode 100644 django-stubs/core/checks/security/__init__.pyi create mode 100644 django-stubs/core/checks/security/base.pyi create mode 100644 django-stubs/core/checks/security/csrf.pyi create mode 100644 django-stubs/core/checks/security/sessions.pyi create mode 100644 django-stubs/core/checks/templates.pyi create mode 100644 django-stubs/core/checks/urls.pyi create mode 100644 django-stubs/core/exceptions.pyi create mode 100644 django-stubs/core/files/images.pyi create mode 100644 django-stubs/core/files/locks.pyi create mode 100644 django-stubs/core/files/move.pyi create mode 100644 django-stubs/core/files/storage.pyi create mode 100644 django-stubs/core/handlers/__init__.pyi create mode 100644 django-stubs/core/handlers/base.pyi create mode 100644 django-stubs/core/handlers/exception.pyi create mode 100644 django-stubs/core/handlers/wsgi.pyi create mode 100644 django-stubs/core/mail/__init__.pyi create mode 100644 django-stubs/core/mail/message.pyi create mode 100644 django-stubs/core/mail/utils.pyi create mode 100644 django-stubs/core/management/__init__.pyi create mode 100644 django-stubs/core/management/base.pyi create mode 100644 django-stubs/core/management/color.pyi create mode 100644 django-stubs/core/management/sql.pyi create mode 100644 django-stubs/core/management/templates.pyi create mode 100644 django-stubs/core/management/utils.pyi create mode 100644 django-stubs/core/paginator.pyi create mode 100644 django-stubs/core/serializers/__init__.pyi create mode 100644 django-stubs/core/serializers/base.pyi create mode 100644 django-stubs/core/serializers/json.pyi create mode 100644 django-stubs/core/serializers/python.pyi create mode 100644 django-stubs/core/servers/__init__.pyi create mode 100644 django-stubs/core/servers/basehttp.pyi create mode 100644 django-stubs/core/signing.pyi create mode 100644 django-stubs/core/validators.pyi create mode 100644 django-stubs/core/wsgi.pyi diff --git a/django-stubs-generated/db/migrations/__init__.pyi b/django-stubs-generated/db/migrations/__init__.pyi deleted file mode 100644 index bf1bdcd..0000000 --- a/django-stubs-generated/db/migrations/__init__.pyi +++ /dev/null @@ -1,6 +0,0 @@ -# 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 * diff --git a/django-stubs-generated/db/migrations/autodetector.pyi b/django-stubs-generated/db/migrations/autodetector.pyi deleted file mode 100644 index 5f78c5c..0000000 --- a/django-stubs-generated/db/migrations/autodetector.pyi +++ /dev/null @@ -1,69 +0,0 @@ -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 - -from .topological_sort import stable_topological_sort - -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: ... diff --git a/django-stubs-generated/db/migrations/exceptions.pyi b/django-stubs-generated/db/migrations/exceptions.pyi deleted file mode 100644 index 4d9ef62..0000000 --- a/django-stubs-generated/db/migrations/exceptions.pyi +++ /dev/null @@ -1,20 +0,0 @@ -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): ... diff --git a/django-stubs-generated/db/migrations/executor.pyi b/django-stubs-generated/db/migrations/executor.pyi deleted file mode 100644 index b831938..0000000 --- a/django-stubs-generated/db/migrations/executor.pyi +++ /dev/null @@ -1,42 +0,0 @@ -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 django.db.migrations.state import ProjectState - -from .exceptions import InvalidMigrationPlan -from .loader import MigrationLoader -from .recorder import MigrationRecorder -from .state import ProjectState - -class MigrationExecutor: - connection: django.db.backends.sqlite3.base.DatabaseWrapper = ... - 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]: ... diff --git a/django-stubs-generated/db/migrations/graph.pyi b/django-stubs-generated/db/migrations/graph.pyi deleted file mode 100644 index 93ecc81..0000000 --- a/django-stubs-generated/db/migrations/graph.pyi +++ /dev/null @@ -1,62 +0,0 @@ -from typing import Any, Callable, List, Optional, Tuple, Union - -from django.db.migrations.migration import Migration, SwappableTuple -from django.db.migrations.state import ProjectState - -from .exceptions import CircularDependencyError, NodeNotFoundError - -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: ... diff --git a/django-stubs-generated/db/migrations/loader.pyi b/django-stubs-generated/db/migrations/loader.pyi deleted file mode 100644 index 948c9d3..0000000 --- a/django-stubs-generated/db/migrations/loader.pyi +++ /dev/null @@ -1,39 +0,0 @@ -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 - -from .exceptions import AmbiguityError, BadMigrationError, InconsistentMigrationHistory, NodeNotFoundError - -MIGRATIONS_MODULE_NAME: str - -class MigrationLoader: - connection: django.db.backends.sqlite3.base.DatabaseWrapper = ... - 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: ... diff --git a/django-stubs-generated/db/migrations/migration.pyi b/django-stubs-generated/db/migrations/migration.pyi deleted file mode 100644 index 8c99ab3..0000000 --- a/django-stubs-generated/db/migrations/migration.pyi +++ /dev/null @@ -1,30 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/operations/__init__.pyi b/django-stubs-generated/db/migrations/operations/__init__.pyi deleted file mode 100644 index 311074d..0000000 --- a/django-stubs-generated/db/migrations/operations/__init__.pyi +++ /dev/null @@ -1,60 +0,0 @@ -# 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", -] diff --git a/django-stubs-generated/db/migrations/operations/base.pyi b/django-stubs-generated/db/migrations/operations/base.pyi deleted file mode 100644 index b4f1d04..0000000 --- a/django-stubs-generated/db/migrations/operations/base.pyi +++ /dev/null @@ -1,18 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/operations/fields.pyi b/django-stubs-generated/db/migrations/operations/fields.pyi deleted file mode 100644 index 6dd0499..0000000 --- a/django-stubs-generated/db/migrations/operations/fields.pyi +++ /dev/null @@ -1,77 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/operations/models.pyi b/django-stubs-generated/db/migrations/operations/models.pyi deleted file mode 100644 index a081d84..0000000 --- a/django-stubs-generated/db/migrations/operations/models.pyi +++ /dev/null @@ -1,173 +0,0 @@ -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): ... diff --git a/django-stubs-generated/db/migrations/operations/special.pyi b/django-stubs-generated/db/migrations/operations/special.pyi deleted file mode 100644 index aa09606..0000000 --- a/django-stubs-generated/db/migrations/operations/special.pyi +++ /dev/null @@ -1,74 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/operations/utils.pyi b/django-stubs-generated/db/migrations/operations/utils.pyi deleted file mode 100644 index 0556645..0000000 --- a/django-stubs-generated/db/migrations/operations/utils.pyi +++ /dev/null @@ -1,6 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/optimizer.pyi b/django-stubs-generated/db/migrations/optimizer.pyi deleted file mode 100644 index 217c405..0000000 --- a/django-stubs-generated/db/migrations/optimizer.pyi +++ /dev/null @@ -1,7 +0,0 @@ -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]: ... diff --git a/django-stubs-generated/db/migrations/questioner.pyi b/django-stubs-generated/db/migrations/questioner.pyi deleted file mode 100644 index b05611f..0000000 --- a/django-stubs-generated/db/migrations/questioner.pyi +++ /dev/null @@ -1,43 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/recorder.pyi b/django-stubs-generated/db/migrations/recorder.pyi deleted file mode 100644 index c215962..0000000 --- a/django-stubs-generated/db/migrations/recorder.pyi +++ /dev/null @@ -1,27 +0,0 @@ -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: django.db.backends.sqlite3.base.DatabaseWrapper = ... - 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: ... diff --git a/django-stubs-generated/db/migrations/serializer.pyi b/django-stubs-generated/db/migrations/serializer.pyi deleted file mode 100644 index dca550d..0000000 --- a/django-stubs-generated/db/migrations/serializer.pyi +++ /dev/null @@ -1,86 +0,0 @@ -from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union - -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: django.db.models.fields.AutoField - 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: ... diff --git a/django-stubs-generated/db/migrations/state.pyi b/django-stubs-generated/db/migrations/state.pyi deleted file mode 100644 index e3da20f..0000000 --- a/django-stubs-generated/db/migrations/state.pyi +++ /dev/null @@ -1,84 +0,0 @@ -from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Type, Union - -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 - -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: - all_models: collections.defaultdict - app_configs: collections.OrderedDict - 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: ... diff --git a/django-stubs-generated/db/migrations/topological_sort.pyi b/django-stubs-generated/db/migrations/topological_sort.pyi deleted file mode 100644 index 1f3cf19..0000000 --- a/django-stubs-generated/db/migrations/topological_sort.pyi +++ /dev/null @@ -1,8 +0,0 @@ -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]: ... diff --git a/django-stubs-generated/db/migrations/utils.pyi b/django-stubs-generated/db/migrations/utils.pyi deleted file mode 100644 index c506ba5..0000000 --- a/django-stubs-generated/db/migrations/utils.pyi +++ /dev/null @@ -1,13 +0,0 @@ -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: ... diff --git a/django-stubs-generated/db/migrations/writer.pyi b/django-stubs-generated/db/migrations/writer.pyi deleted file mode 100644 index 78b919d..0000000 --- a/django-stubs-generated/db/migrations/writer.pyi +++ /dev/null @@ -1,36 +0,0 @@ -from typing import Any, Optional, Set, Tuple, Type - -from django.db.migrations.migration import Migration -from django.db.migrations.operations.base import Operation - -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: django.db.migrations.operations.models.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 diff --git a/django-stubs-generated/db/models/query.pyi b/django-stubs-generated/db/models/query.pyi index 9fc569a..bb18198 100644 --- a/django-stubs-generated/db/models/query.pyi +++ b/django-stubs-generated/db/models/query.pyi @@ -4,7 +4,22 @@ from collections import OrderedDict from datetime import date, datetime from decimal import Decimal from itertools import chain -from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, Generic, TypeVar, overload +from typing import ( + Any, + Callable, + Dict, + Iterator, + List, + Optional, + Set, + Tuple, + Type, + Union, + Generic, + TypeVar, + overload, + Sequence, +) from unittest.mock import MagicMock from uuid import UUID @@ -99,15 +114,9 @@ class QuerySet(Generic[_T]): def count(self) -> int: ... def get(self, *args: Any, **kwargs: Any) -> _T: ... def create(self, **kwargs: Any) -> _T: ... - def bulk_create(self, objs: Union[Iterator[Any], List[Model]], batch_size: Optional[int] = ...) -> List[_T]: ... - def get_or_create( - self, defaults: Optional[Union[Dict[str, date], Dict[str, Model]]] = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... - def update_or_create( - self, - defaults: Optional[Union[Dict[str, Callable], Dict[str, date], Dict[str, Model], Dict[str, str]]] = ..., - **kwargs: Any - ) -> Tuple[_T, bool]: ... + def bulk_create(self, objs: Sequence[Model], batch_size: Optional[int] = ...) -> List[_T]: ... + def get_or_create(self, defaults: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + def update_or_create(self, defaults: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... def first(self) -> Optional[Union[Dict[str, int], _T]]: ... diff --git a/django-stubs/core/cache/__init__.pyi b/django-stubs/core/cache/__init__.pyi new file mode 100644 index 0000000..1e431c9 --- /dev/null +++ b/django-stubs/core/cache/__init__.pyi @@ -0,0 +1,21 @@ +from collections import OrderedDict +from typing import Any, Callable, Dict, Union + +from django.core.cache.backends.base import BaseCache as BaseCache + +DEFAULT_CACHE_ALIAS: str + +class CacheHandler: + def __init__(self) -> None: ... + def __getitem__(self, alias: str) -> BaseCache: ... + def all(self): ... + +class DefaultCacheProxy: + def __getattr__(self, name: str) -> Union[Callable, Dict[str, float], OrderedDict, int]: ... + def __setattr__(self, name: str, value: Callable) -> None: ... + def __delattr__(self, name: Any): ... + def __contains__(self, key: str) -> bool: ... + def __eq__(self, other: Any): ... + +cache: Any +caches: CacheHandler diff --git a/django-stubs/core/cache/backends/__init__.pyi b/django-stubs/core/cache/backends/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/django-stubs/core/cache/backends/base.pyi b/django-stubs/core/cache/backends/base.pyi new file mode 100644 index 0000000..29aede9 --- /dev/null +++ b/django-stubs/core/cache/backends/base.pyi @@ -0,0 +1,47 @@ +from collections import OrderedDict +from typing import Any, Callable, Dict, List, Optional, Union + +from django.core.exceptions import ImproperlyConfigured + +class InvalidCacheBackendError(ImproperlyConfigured): ... +class CacheKeyWarning(RuntimeWarning): ... + +DEFAULT_TIMEOUT: Any +MEMCACHE_MAX_KEY_LENGTH: int + +def default_key_func(key: Union[int, str], key_prefix: str, version: Union[int, str]) -> str: ... +def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ... + +class BaseCache: + default_timeout: int = ... + key_prefix: str = ... + version: int = ... + key_func: Callable = ... + def __init__(self, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ... + def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ... + def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> str: ... + def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... + def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> None: ... + def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... + def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... + def delete(self, key: Any, version: Optional[Any] = ...) -> None: ... + def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ... + def get_or_set( + self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ... + ) -> Optional[Union[int, str]]: ... + def has_key(self, key: Any, version: Optional[Any] = ...): ... + def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... + def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... + def __contains__(self, key: str) -> bool: ... + def set_many( + self, + data: Union[Dict[str, bytes], Dict[str, int], Dict[str, str], OrderedDict], + timeout: Any = ..., + version: Optional[Union[int, str]] = ..., + ) -> List[Any]: ... + def delete_many(self, keys: Union[Dict[str, str], List[str]], version: None = ...) -> None: ... + def clear(self) -> None: ... + def validate_key(self, key: str) -> None: ... + def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... + def decr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... + def close(self, **kwargs: Any) -> None: ... diff --git a/django-stubs/core/cache/backends/db.pyi b/django-stubs/core/cache/backends/db.pyi new file mode 100644 index 0000000..f20e31a --- /dev/null +++ b/django-stubs/core/cache/backends/db.pyi @@ -0,0 +1,39 @@ +from typing import Any, Callable, Dict, Optional, Union + +from django.core.cache.backends.base import BaseCache + +class Options: + db_table: str = ... + app_label: str = ... + model_name: str = ... + verbose_name: str = ... + verbose_name_plural: str = ... + object_name: str = ... + abstract: bool = ... + managed: bool = ... + proxy: bool = ... + swapped: bool = ... + def __init__(self, table: str) -> None: ... + +class BaseDatabaseCache(BaseCache): + default_timeout: int + key_func: Callable + key_prefix: str + version: int + cache_model_class: Any = ... + def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ... + +class DatabaseCache(BaseDatabaseCache): + default_timeout: int + key_func: Callable + key_prefix: str + version: int + def get(self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...) -> Any: ... + def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ... + def add( + self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ... + ) -> bool: ... + def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ... + def delete(self, key: str, version: Optional[int] = ...) -> None: ... + def has_key(self, key: str, version: Optional[int] = ...) -> Any: ... + def clear(self) -> None: ... diff --git a/django-stubs/core/cache/backends/dummy.pyi b/django-stubs/core/cache/backends/dummy.pyi new file mode 100644 index 0000000..78ec150 --- /dev/null +++ b/django-stubs/core/cache/backends/dummy.pyi @@ -0,0 +1,19 @@ +from typing import Any, Dict, Optional, Union + +from django.core.cache.backends.base import BaseCache + +class DummyCache(BaseCache): + default_timeout: int + key_func: Callable + key_prefix: str + version: int + def __init__(self, host: str, *args: Any, **kwargs: Any) -> None: ... + def add(self, key: str, value: str, timeout: Any = ..., version: None = ...) -> bool: ... + def get(self, key: str, default: Optional[str] = ..., version: Optional[int] = ...) -> Optional[str]: ... + def set( + self, key: str, value: Union[Dict[str, Any], int, str], timeout: Any = ..., version: Optional[str] = ... + ) -> None: ... + def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ... + def delete(self, key: str, version: None = ...) -> None: ... + def has_key(self, key: str, version: None = ...) -> bool: ... + def clear(self) -> None: ... diff --git a/django-stubs/core/cache/backends/filebased.pyi b/django-stubs/core/cache/backends/filebased.pyi new file mode 100644 index 0000000..8a01b34 --- /dev/null +++ b/django-stubs/core/cache/backends/filebased.pyi @@ -0,0 +1,22 @@ +from typing import Any, Callable, Dict, Optional, Union + +from django.core.cache.backends.base import BaseCache + +class FileBasedCache(BaseCache): + default_timeout: int + key_func: Callable + key_prefix: str + version: int + cache_suffix: str = ... + def __init__(self, dir: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ... + def add( + self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ... + ) -> bool: ... + def get( + self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ... + ) -> Optional[str]: ... + def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ... + def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ... + def delete(self, key: str, version: Optional[int] = ...) -> None: ... + def has_key(self, key: str, version: Optional[int] = ...) -> bool: ... + def clear(self) -> None: ... diff --git a/django-stubs/core/cache/backends/locmem.pyi b/django-stubs/core/cache/backends/locmem.pyi new file mode 100644 index 0000000..8c32dca --- /dev/null +++ b/django-stubs/core/cache/backends/locmem.pyi @@ -0,0 +1,26 @@ +from typing import Any, Callable, Dict, Optional, Union + +from django.core.cache.backends.base import BaseCache + +class LocMemCache(BaseCache): + default_timeout: int + key_func: Callable + key_prefix: str + version: int + def __init__(self, name: str, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ... + def add( + self, + key: str, + value: Union[Dict[str, int], Dict[str, str], bytes, int, str], + timeout: Any = ..., + version: Optional[int] = ..., + ) -> Any: ... + def get( + self, key: Union[int, str], default: Optional[Union[int, str]] = ..., version: Optional[int] = ... + ) -> Any: ... + def set(self, key: Union[int, str], value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ... + def touch(self, key: str, timeout: Any = ..., version: None = ...) -> Any: ... + def incr(self, key: Union[int, str], delta: int = ..., version: Optional[int] = ...) -> int: ... + def has_key(self, key: str, version: Optional[int] = ...) -> Any: ... + def delete(self, key: str, version: Optional[int] = ...) -> None: ... + def clear(self) -> None: ... diff --git a/django-stubs/core/cache/utils.pyi b/django-stubs/core/cache/utils.pyi new file mode 100644 index 0000000..ea5d6e5 --- /dev/null +++ b/django-stubs/core/cache/utils.pyi @@ -0,0 +1,5 @@ +from typing import Any, List, Optional, Union + +TEMPLATE_FRAGMENT_KEY_TEMPLATE: str + +def make_template_fragment_key(fragment_name: str, vary_on: Optional[Union[List[int], List[str]]] = ...) -> str: ... diff --git a/django-stubs/core/checks/__init__.pyi b/django-stubs/core/checks/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/django-stubs/core/checks/caches.pyi b/django-stubs/core/checks/caches.pyi new file mode 100644 index 0000000..ddc5c91 --- /dev/null +++ b/django-stubs/core/checks/caches.pyi @@ -0,0 +1,7 @@ +from typing import Any, List, Optional + +from django.core.checks.messages import Error + +E001: Any + +def check_default_cache_is_configured(app_configs: None, **kwargs: Any) -> List[Error]: ... diff --git a/django-stubs/core/checks/database.pyi b/django-stubs/core/checks/database.pyi new file mode 100644 index 0000000..a3167ff --- /dev/null +++ b/django-stubs/core/checks/database.pyi @@ -0,0 +1,3 @@ +from typing import Any, List, Optional + +def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/core/checks/messages.pyi b/django-stubs/core/checks/messages.pyi new file mode 100644 index 0000000..a66acf9 --- /dev/null +++ b/django-stubs/core/checks/messages.pyi @@ -0,0 +1,45 @@ +from typing import Any, Optional, Union + +DEBUG: int +INFO: int +WARNING: int +ERROR: int +CRITICAL: int + +class CheckMessage: + level: Any = ... + msg: Any = ... + hint: Any = ... + obj: Any = ... + id: Any = ... + def __init__( + self, level: int, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ... + ) -> None: ... + def __eq__(self, other: Union[CheckMessage, str]) -> bool: ... + def is_serious(self, level: int = ...) -> bool: ... + def is_silenced(self) -> bool: ... + +class Debug(CheckMessage): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class Info(CheckMessage): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class Warning(CheckMessage): + hint: str + id: str + level: int + msg: str + obj: Any + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class Error(CheckMessage): + hint: None + id: str + level: int + msg: str + obj: Any + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class Critical(CheckMessage): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/core/checks/model_checks.pyi b/django-stubs/core/checks/model_checks.pyi new file mode 100644 index 0000000..23fd841 --- /dev/null +++ b/django-stubs/core/checks/model_checks.pyi @@ -0,0 +1,6 @@ +from typing import Any, List, Optional + +from django.core.checks.messages import Warning + +def check_all_models(app_configs: None = ..., **kwargs: Any) -> List[Warning]: ... +def check_lazy_references(app_configs: None = ..., **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/core/checks/registry.pyi b/django-stubs/core/checks/registry.pyi new file mode 100644 index 0000000..cfb6667 --- /dev/null +++ b/django-stubs/core/checks/registry.pyi @@ -0,0 +1,35 @@ +from typing import Any, Callable, List, Optional, Set, Union + +from django.apps.config import AppConfig +from django.core.checks.messages import CheckMessage + +class Tags: + admin: str = ... + caches: str = ... + compatibility: str = ... + database: str = ... + models: str = ... + security: str = ... + signals: str = ... + templates: str = ... + urls: str = ... + +class CheckRegistry: + registered_checks: Set[Callable] = ... + deployment_checks: Set[Callable] = ... + def __init__(self) -> None: ... + def register(self, check: Optional[Union[Callable, str]] = ..., *tags: Any, **kwargs: Any) -> Callable: ... + def run_checks( + self, + app_configs: Optional[List[AppConfig]] = ..., + tags: Optional[List[str]] = ..., + include_deployment_checks: bool = ..., + ) -> Union[List[CheckMessage], List[int], List[str]]: ... + def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ... + def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ... + def get_checks(self, include_deployment_checks: bool = ...) -> List[Callable]: ... + +registry: Any +register: Any +run_checks: Any +tag_exists: Any diff --git a/django-stubs/core/checks/security/__init__.pyi b/django-stubs/core/checks/security/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/django-stubs/core/checks/security/base.pyi b/django-stubs/core/checks/security/base.pyi new file mode 100644 index 0000000..d66c190 --- /dev/null +++ b/django-stubs/core/checks/security/base.pyi @@ -0,0 +1,31 @@ +from typing import Any, List, Optional + +from django.core.checks.messages import Warning + +SECRET_KEY_MIN_LENGTH: int +SECRET_KEY_MIN_UNIQUE_CHARACTERS: int +W001: Any +W002: Any +W004: Any +W005: Any +W006: Any +W007: Any +W008: Any +W009: Any +W018: Any +W019: Any +W020: Any +W021: Any + +def check_security_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_xframe_options_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_sts(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_sts_include_subdomains(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_sts_preload(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_content_type_nosniff(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_xss_filter(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_ssl_redirect(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_secret_key(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_debug(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_xframe_deny(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_allowed_hosts(app_configs: None, **kwargs: Any) -> List[Warning]: ... diff --git a/django-stubs/core/checks/security/csrf.pyi b/django-stubs/core/checks/security/csrf.pyi new file mode 100644 index 0000000..b422356 --- /dev/null +++ b/django-stubs/core/checks/security/csrf.pyi @@ -0,0 +1,9 @@ +from typing import Any, List, Optional + +from django.core.checks.messages import Warning + +W003: Any +W016: Any + +def check_csrf_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_csrf_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ... diff --git a/django-stubs/core/checks/security/sessions.pyi b/django-stubs/core/checks/security/sessions.pyi new file mode 100644 index 0000000..bd9f8c7 --- /dev/null +++ b/django-stubs/core/checks/security/sessions.pyi @@ -0,0 +1,18 @@ +from typing import Any, List, Optional + +from django.core.checks.messages import Warning + +def add_session_cookie_message(message: Any): ... + +W010: Any +W011: Any +W012: Any + +def add_httponly_message(message: Any): ... + +W013: Any +W014: Any +W015: Any + +def check_session_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def check_session_cookie_httponly(app_configs: None, **kwargs: Any) -> List[Warning]: ... diff --git a/django-stubs/core/checks/templates.pyi b/django-stubs/core/checks/templates.pyi new file mode 100644 index 0000000..3884dad --- /dev/null +++ b/django-stubs/core/checks/templates.pyi @@ -0,0 +1,9 @@ +from typing import Any, List, Optional + +from django.core.checks.messages import Error + +E001: Any +E002: Any + +def check_setting_app_dirs_loaders(app_configs: None, **kwargs: Any) -> List[Error]: ... +def check_string_if_invalid_is_string(app_configs: None, **kwargs: Any) -> List[Error]: ... diff --git a/django-stubs/core/checks/urls.pyi b/django-stubs/core/checks/urls.pyi new file mode 100644 index 0000000..b432e17 --- /dev/null +++ b/django-stubs/core/checks/urls.pyi @@ -0,0 +1,11 @@ +from typing import Any, Callable, List, Optional, Tuple, Union + +from django.core.checks.messages import CheckMessage, Error, Warning +from django.urls.resolvers import URLPattern, URLResolver + +def check_url_config(app_configs: None, **kwargs: Any) -> List[CheckMessage]: ... +def check_resolver(resolver: Union[Tuple[str, Callable], URLPattern, URLResolver]) -> List[CheckMessage]: ... +def check_url_namespaces_unique(app_configs: None, **kwargs: Any) -> List[Warning]: ... +def get_warning_for_invalid_pattern(pattern: Any) -> List[Error]: ... +def check_url_settings(app_configs: None, **kwargs: Any) -> List[Error]: ... +def E006(name: str) -> Error: ... diff --git a/django-stubs/core/exceptions.pyi b/django-stubs/core/exceptions.pyi new file mode 100644 index 0000000..dab34dc --- /dev/null +++ b/django-stubs/core/exceptions.pyi @@ -0,0 +1,58 @@ +from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union + +from django.db.models.base import Model +from django.forms.utils import ErrorDict, ErrorList + +class FieldDoesNotExist(Exception): ... +class AppRegistryNotReady(Exception): ... + +class ObjectDoesNotExist(Exception): + silent_variable_failure: bool = ... + +class MultipleObjectsReturned(Exception): ... +class SuspiciousOperation(Exception): ... +class SuspiciousMultipartForm(SuspiciousOperation): ... +class SuspiciousFileOperation(SuspiciousOperation): ... +class DisallowedHost(SuspiciousOperation): ... +class DisallowedRedirect(SuspiciousOperation): ... +class TooManyFieldsSent(SuspiciousOperation): ... +class RequestDataTooBig(SuspiciousOperation): ... +class PermissionDenied(Exception): ... +class ViewDoesNotExist(Exception): ... +class MiddlewareNotUsed(Exception): ... +class ImproperlyConfigured(Exception): ... +class FieldError(Exception): ... + +NON_FIELD_ERRORS: str + +class ValidationError(Exception): + error_dict: Any = ... + error_list: Any = ... + message: Any = ... + code: Any = ... + params: Any = ... + def __init__( + self, + message: Union[ + Dict[str, List[ValidationError]], + Dict[str, ErrorList], + List[Union[ValidationError, str]], + ValidationError, + ErrorList, + str, + ], + code: Optional[str] = ..., + params: Optional[ + Union[Dict[str, Union[Tuple[str], Type[Model], Model, str]], Dict[str, Union[int, str]]] + ] = ..., + ) -> None: ... + @property + def message_dict(self) -> Dict[str, List[str]]: ... + @property + def messages(self) -> List[str]: ... + def update_error_dict( + self, error_dict: Union[Dict[str, List[ValidationError]], ErrorDict] + ) -> Union[Dict[str, List[ValidationError]], ErrorDict]: ... + def __iter__(self) -> Iterator[Union[Tuple[str, List[str]], str]]: ... + +class EmptyResultSet(Exception): ... diff --git a/django-stubs/core/files/__init__.pyi b/django-stubs/core/files/__init__.pyi index d046aca..af01506 100644 --- a/django-stubs/core/files/__init__.pyi +++ b/django-stubs/core/files/__init__.pyi @@ -1,3 +1,3 @@ -from django.core.files.base import File +from django.core.files.base import File as File __all__ = ["File"] diff --git a/django-stubs/core/files/images.pyi b/django-stubs/core/files/images.pyi new file mode 100644 index 0000000..36b737f --- /dev/null +++ b/django-stubs/core/files/images.pyi @@ -0,0 +1,15 @@ +from io import BufferedReader, BytesIO +from typing import Any, Union + +from django.core.files import File + +class ImageFile(File): + file: BufferedReader + mode: str + name: str + @property + def width(self) -> int: ... + @property + def height(self) -> int: ... + +def get_image_dimensions(file_or_path: Union[BufferedReader, BytesIO, ImageFile, str], close: bool = ...) -> Any: ... diff --git a/django-stubs/core/files/locks.pyi b/django-stubs/core/files/locks.pyi new file mode 100644 index 0000000..56724de --- /dev/null +++ b/django-stubs/core/files/locks.pyi @@ -0,0 +1,17 @@ +from ctypes import Structure, c_int64, c_ulong, c_void_p +from io import BufferedRandom, TextIOWrapper +from typing import Union + +LOCK_SH: int +LOCK_NB: int +LOCK_EX: int +ULONG_PTR = c_int64 +ULONG_PTR = c_ulong +PVOID = c_void_p + +class _OFFSET(Structure): ... +class _OFFSET_UNION(Union): ... +class OVERLAPPED(Structure): ... + +def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ... +def unlock(f: Union[BufferedRandom, int]) -> bool: ... diff --git a/django-stubs/core/files/move.pyi b/django-stubs/core/files/move.pyi new file mode 100644 index 0000000..bdbfd17 --- /dev/null +++ b/django-stubs/core/files/move.pyi @@ -0,0 +1,3 @@ +def file_move_safe( + old_file_name: str, new_file_name: str, chunk_size: int = ..., allow_overwrite: bool = ... +) -> None: ... diff --git a/django-stubs/core/files/storage.pyi b/django-stubs/core/files/storage.pyi new file mode 100644 index 0000000..2c1af70 --- /dev/null +++ b/django-stubs/core/files/storage.pyi @@ -0,0 +1,51 @@ +from datetime import datetime +from io import StringIO, TextIOWrapper +from typing import Any, List, Optional, Tuple, Union + +from django.core.files.base import File +from django.utils.functional import LazyObject + +class Storage: + def open(self, name: str, mode: str = ...) -> File: ... + def save( + self, name: Optional[str], content: Union[StringIO, TextIOWrapper, File], max_length: Optional[int] = ... + ) -> str: ... + def get_valid_name(self, name: str) -> str: ... + def get_available_name(self, name: str, max_length: Optional[int] = ...) -> str: ... + def generate_filename(self, filename: str) -> str: ... + def path(self, name: str) -> Any: ... + def delete(self, name: Any) -> None: ... + def exists(self, name: Any) -> None: ... + def listdir(self, path: Any) -> None: ... + def size(self, name: Any) -> None: ... + def url(self, name: Any) -> None: ... + def get_accessed_time(self, name: Any) -> None: ... + def get_created_time(self, name: Any) -> None: ... + def get_modified_time(self, name: Any) -> None: ... + +class FileSystemStorage(Storage): + def __init__( + self, + location: Optional[str] = ..., + base_url: Optional[str] = ..., + file_permissions_mode: Optional[int] = ..., + directory_permissions_mode: Optional[int] = ..., + ) -> None: ... + def base_location(self) -> str: ... + def location(self) -> str: ... + def base_url(self) -> str: ... + def file_permissions_mode(self) -> Optional[int]: ... + def directory_permissions_mode(self) -> Optional[int]: ... + def delete(self, name: str) -> None: ... + def exists(self, name: str) -> bool: ... + def listdir(self, path: str) -> Tuple[List[str], List[str]]: ... + def path(self, name: str) -> str: ... + def size(self, name: str) -> int: ... + def url(self, name: Optional[str]) -> str: ... + def get_accessed_time(self, name: str) -> datetime: ... + def get_created_time(self, name: str) -> datetime: ... + def get_modified_time(self, name: str) -> datetime: ... + +class DefaultStorage(LazyObject): ... + +default_storage: Any diff --git a/django-stubs/core/handlers/__init__.pyi b/django-stubs/core/handlers/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/django-stubs/core/handlers/base.pyi b/django-stubs/core/handlers/base.pyi new file mode 100644 index 0000000..c15523a --- /dev/null +++ b/django-stubs/core/handlers/base.pyi @@ -0,0 +1,13 @@ +from typing import Any, Callable + +from django.core.handlers.wsgi import WSGIRequest +from django.http.response import HttpResponse, HttpResponseBase + +logger: Any + +class BaseHandler: + def load_middleware(self) -> None: ... + def make_view_atomic(self, view: Callable) -> Callable: ... + def get_exception_response(self, request: Any, resolver: Any, status_code: Any, exception: Any): ... + def get_response(self, request: WSGIRequest) -> HttpResponseBase: ... + def process_exception_by_middleware(self, exception: Exception, request: WSGIRequest) -> HttpResponse: ... diff --git a/django-stubs/core/handlers/exception.pyi b/django-stubs/core/handlers/exception.pyi new file mode 100644 index 0000000..115a69d --- /dev/null +++ b/django-stubs/core/handlers/exception.pyi @@ -0,0 +1,12 @@ +from typing import Any, Callable + +from django.core.handlers.wsgi import WSGIRequest +from django.http.response import HttpResponse +from django.urls.resolvers import URLResolver + +def convert_exception_to_response(get_response: Callable) -> Callable: ... +def response_for_exception(request: WSGIRequest, exc: Exception) -> HttpResponse: ... +def get_exception_response( + request: WSGIRequest, resolver: URLResolver, status_code: int, exception: Exception, sender: None = ... +) -> HttpResponse: ... +def handle_uncaught_exception(request: Any, resolver: Any, exc_info: Any): ... diff --git a/django-stubs/core/handlers/wsgi.pyi b/django-stubs/core/handlers/wsgi.pyi new file mode 100644 index 0000000..bfb1891 --- /dev/null +++ b/django-stubs/core/handlers/wsgi.pyi @@ -0,0 +1,52 @@ +from io import BytesIO +from typing import Any, Callable, Dict, Optional, Union + +from django.contrib.auth.models import AbstractUser +from django.contrib.sessions.backends.base import SessionBase +from django.http.request import QueryDict +from django.http.response import HttpResponse +from django.utils.datastructures import MultiValueDict + +from django.core.handlers import base +from django.http import HttpRequest + +_Stream = Union[BytesIO, str] + +class LimitedStream: + stream: _Stream = ... + remaining: int = ... + buffer: bytes = ... + buf_size: int = ... + def __init__(self, stream: _Stream, limit: int, buf_size: int = ...) -> None: ... + def read(self, size: Optional[int] = ...) -> bytes: ... + def readline(self, size: Optional[int] = ...) -> bytes: ... + +class WSGIRequest(HttpRequest): + content_params: Dict[str, str] + content_type: str + environ: Dict[str, Any] = ... + path_info: str = ... + path: str = ... + user: AbstractUser + session: SessionBase + + META: Dict[str, Any] = ... + method: str = ... + encoding: Any = ... + resolver_match: None = ... + def __init__(self, environ: Dict[str, Any]) -> None: ... + def GET(self) -> QueryDict: ... + def COOKIES(self) -> Dict[str, str]: ... + @property + def FILES(self) -> MultiValueDict: ... + POST: Any = ... + +class WSGIHandler(base.BaseHandler): + request_class: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __call__(self, environ: Dict[str, Any], start_response: Callable) -> HttpResponse: ... + +def get_path_info(environ: Dict[str, Any]) -> str: ... +def get_script_name(environ: Dict[str, Any]) -> str: ... +def get_bytes_from_wsgi(environ: Dict[str, Any], key: str, default: str) -> bytes: ... +def get_str_from_wsgi(environ: Dict[str, Any], key: str, default: str) -> str: ... diff --git a/django-stubs/core/mail/__init__.pyi b/django-stubs/core/mail/__init__.pyi new file mode 100644 index 0000000..31b3330 --- /dev/null +++ b/django-stubs/core/mail/__init__.pyi @@ -0,0 +1,47 @@ +from typing import Any, List, Optional, Tuple + +from django.core.mail.backends.base import BaseEmailBackend +from django.core.mail.message import DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE +from django.core.mail.message import BadHeaderError as BadHeaderError +from django.core.mail.message import EmailMessage as EmailMessage +from django.core.mail.message import EmailMultiAlternatives as EmailMultiAlternatives +from django.core.mail.message import SafeMIMEMultipart as SafeMIMEMultipart +from django.core.mail.message import SafeMIMEText as SafeMIMEText +from django.core.mail.message import forbid_multi_line_headers as forbid_multi_line_headers +from django.core.mail.message import make_msgid as make_msgid +from django.core.mail.utils import DNS_NAME as DNS_NAME +from django.core.mail.utils import CachedDnsName as CachedDnsName + +def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> BaseEmailBackend: ... +def send_mail( + subject: str, + message: str, + from_email: Optional[str], + recipient_list: List[str], + fail_silently: bool = ..., + auth_user: None = ..., + auth_password: None = ..., + connection: Optional[BaseEmailBackend] = ..., + html_message: Optional[str] = ..., +) -> int: ... +def send_mass_mail( + datatuple: List[Tuple[str, str, str, List[str]]], + fail_silently: bool = ..., + auth_user: None = ..., + auth_password: None = ..., + connection: BaseEmailBackend = ..., +) -> int: ... +def mail_admins( + subject: str, + message: str, + fail_silently: bool = ..., + connection: Optional[BaseEmailBackend] = ..., + html_message: Optional[str] = ..., +) -> None: ... +def mail_managers( + subject: str, + message: str, + fail_silently: bool = ..., + connection: Optional[BaseEmailBackend] = ..., + html_message: Optional[str] = ..., +) -> None: ... diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi new file mode 100644 index 0000000..1a1fb3a --- /dev/null +++ b/django-stubs/core/mail/message.pyi @@ -0,0 +1,121 @@ +import email +from email.mime.message import MIMEMessage +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText +from typing import Any, Dict, List, Optional, Tuple, Union + +from django.core.mail.backends.base import BaseEmailBackend +from django.utils.safestring import SafeText + +utf8_charset: Any +utf8_charset_qp: Any +DEFAULT_ATTACHMENT_MIME_TYPE: str +RFC5322_EMAIL_LINE_LENGTH_LIMIT: int + +class BadHeaderError(ValueError): ... + +ADDRESS_HEADERS: Any + +def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str, str]: ... +def split_addr(addr: str, encoding: str) -> Tuple[str, str]: ... +def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ... + +class MIMEMixin: + def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ... + def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ... + +class SafeMIMEMessage(MIMEMixin, MIMEMessage): + defects: List[Any] + epilogue: None + policy: email._policybase.Compat32 + preamble: None + def __setitem__(self, name: str, val: str) -> None: ... + +class SafeMIMEText(MIMEMixin, MIMEText): + defects: List[Any] + epilogue: None + policy: email._policybase.Compat32 + preamble: None + encoding: str = ... + def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ... + def __setitem__(self, name: str, val: str) -> None: ... + def set_payload(self, payload: str, charset: str = ...) -> None: ... + +class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): + defects: List[Any] + epilogue: None + policy: email._policybase.Compat32 + preamble: None + encoding: str = ... + def __init__( + self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any + ) -> None: ... + def __setitem__(self, name: str, val: str) -> None: ... + +class EmailMessage: + content_subtype: str = ... + mixed_subtype: str = ... + encoding: Any = ... + to: List[str] = ... + cc: List[Any] = ... + bcc: List[Any] = ... + reply_to: List[Any] = ... + from_email: str = ... + subject: str = ... + body: str = ... + attachments: List[Any] = ... + extra_headers: Dict[Any, Any] = ... + connection: None = ... + def __init__( + self, + subject: str = ..., + body: Optional[str] = ..., + from_email: Optional[str] = ..., + to: Optional[Union[List[str], Tuple[str, str], str]] = ..., + bcc: Optional[Union[List[str], Tuple[str], str]] = ..., + connection: Optional[BaseEmailBackend] = ..., + attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ..., + headers: Optional[Dict[str, str]] = ..., + cc: Optional[Union[List[str], Tuple[str, str], str]] = ..., + reply_to: Optional[Union[List[Optional[str]], str]] = ..., + ) -> None: ... + def get_connection(self, fail_silently: bool = ...) -> BaseEmailBackend: ... + def message(self) -> MIMEMixin: ... + def recipients(self) -> List[str]: ... + def send(self, fail_silently: bool = ...) -> int: ... + def attach( + self, + filename: Optional[Union[MIMEText, str]] = ..., + content: Optional[Union[bytes, EmailMessage, SafeMIMEText, str]] = ..., + mimetype: Optional[str] = ..., + ) -> None: ... + def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ... + +class EmailMultiAlternatives(EmailMessage): + attachments: List[Any] + bcc: List[Any] + body: SafeText + cc: List[Any] + connection: None + extra_headers: Dict[Any, Any] + from_email: str + reply_to: List[Any] + subject: str + to: List[str] + alternative_subtype: str = ... + alternatives: Any = ... + def __init__( + self, + subject: str = ..., + body: str = ..., + from_email: Optional[str] = ..., + to: Optional[List[str]] = ..., + bcc: Optional[List[str]] = ..., + connection: Optional[BaseEmailBackend] = ..., + attachments: None = ..., + headers: Optional[Dict[str, str]] = ..., + alternatives: Optional[List[Tuple[str, str]]] = ..., + cc: None = ..., + reply_to: None = ..., + ) -> None: ... + def attach_alternative(self, content: str, mimetype: str) -> None: ... diff --git a/django-stubs/core/mail/utils.pyi b/django-stubs/core/mail/utils.pyi new file mode 100644 index 0000000..68b3a64 --- /dev/null +++ b/django-stubs/core/mail/utils.pyi @@ -0,0 +1,6 @@ +from typing import Any + +class CachedDnsName: + def get_fqdn(self) -> str: ... + +DNS_NAME: Any diff --git a/django-stubs/core/management/__init__.pyi b/django-stubs/core/management/__init__.pyi new file mode 100644 index 0000000..a357e0f --- /dev/null +++ b/django-stubs/core/management/__init__.pyi @@ -0,0 +1,20 @@ +from typing import Any, Dict, List, Optional, Tuple, Union + +from django.core.management.base import BaseCommand + +def find_commands(management_dir: str) -> List[str]: ... +def load_command_class(app_name: str, name: str) -> BaseCommand: ... +def get_commands() -> Dict[str, str]: ... +def call_command(command_name: Union[Tuple[str], BaseCommand, str], *args: Any, **options: Any) -> Optional[str]: ... + +class ManagementUtility: + argv: List[str] = ... + prog_name: str = ... + settings_exception: None = ... + def __init__(self, argv: List[str] = ...) -> None: ... + def main_help_text(self, commands_only: bool = ...): ... + def fetch_command(self, subcommand: str) -> BaseCommand: ... + def autocomplete(self) -> None: ... + def execute(self) -> None: ... + +def execute_from_command_line(argv: List[str] = ...) -> None: ... diff --git a/django-stubs/core/management/base.pyi b/django-stubs/core/management/base.pyi new file mode 100644 index 0000000..774d2a0 --- /dev/null +++ b/django-stubs/core/management/base.pyi @@ -0,0 +1,92 @@ +from argparse import ArgumentParser, HelpFormatter, Namespace +from io import StringIO, TextIOBase, TextIOWrapper +from typing import Any, Callable, List, Optional, Tuple, Union, Type + +from django.apps.config import AppConfig +from django.core.management.color import Style + +class CommandError(Exception): ... +class SystemCheckError(CommandError): ... + +class CommandParser(ArgumentParser): + add_help: bool + allow_abbrev: bool + argument_default: None + conflict_handler: str + description: str + epilog: None + formatter_class: Type[DjangoHelpFormatter] + fromfile_prefix_chars: None + prefix_chars: str + prog: str + usage: None + missing_args_message: None = ... + called_from_command_line: bool = ... + def __init__(self, **kwargs: Any) -> None: ... + def parse_args(self, args: List[str] = ..., namespace: None = ...) -> Namespace: ... + def error(self, message: str) -> Any: ... + +def handle_default_options(options: Namespace) -> None: ... +def no_translations(handle_func: Callable) -> Callable: ... + +class DjangoHelpFormatter(HelpFormatter): + show_last: Any = ... + def add_usage(self, usage: None, actions: List[Any], *args: Any, **kwargs: Any) -> None: ... + def add_arguments(self, actions: List[Any]) -> None: ... + +class OutputWrapper(TextIOBase): + @property + def style_func(self): ... + @style_func.setter + def style_func(self, style_func: Any): ... + style_func: Any = ... + ending: str = ... + def __init__( + self, out: Union[StringIO, TextIOWrapper], style_func: Optional[Callable] = ..., ending: str = ... + ) -> None: ... + def __getattr__(self, name: str) -> Callable: ... + def isatty(self) -> bool: ... + def write(self, msg: str, style_func: Optional[Callable] = ..., ending: Optional[str] = ...) -> None: ... + +class BaseCommand: + help: str = ... + output_transaction: bool = ... + requires_migrations_checks: bool = ... + requires_system_checks: bool = ... + base_stealth_options: Any = ... + stealth_options: Any = ... + stdout: OutputWrapper = ... + stderr: OutputWrapper = ... + style: Style = ... + def __init__( + self, stdout: Optional[StringIO] = ..., stderr: Optional[StringIO] = ..., no_color: bool = ... + ) -> None: ... + def get_version(self) -> str: ... + def create_parser(self, prog_name: str, subcommand: str) -> CommandParser: ... + def add_arguments(self, parser: CommandParser) -> None: ... + def print_help(self, prog_name: str, subcommand: str) -> None: ... + def run_from_argv(self, argv: List[str]) -> None: ... + def execute(self, *args: Any, **options: Any) -> Optional[Union[Tuple, str]]: ... + def check( + self, + app_configs: Optional[List[AppConfig]] = ..., + tags: Optional[List[str]] = ..., + display_num_errors: bool = ..., + include_deployment_checks: bool = ..., + fail_level: int = ..., + ) -> None: ... + def check_migrations(self) -> None: ... + def handle(self, *args: Any, **options: Any) -> None: ... + +class AppCommand(BaseCommand): + missing_args_message: str = ... + def add_arguments(self, parser: Any) -> None: ... + def handle(self, *app_labels: Any, **options: Any): ... + def handle_app_config(self, app_config: Any, **options: Any) -> None: ... + +class LabelCommand(BaseCommand): + label: str = ... + missing_args_message: Any = ... + def add_arguments(self, parser: CommandParser) -> None: ... + def handle(self, *labels: Any, **options: Any) -> str: ... + def handle_label(self, label: Any, **options: Any) -> None: ... diff --git a/django-stubs/core/management/color.pyi b/django-stubs/core/management/color.pyi new file mode 100644 index 0000000..ed27992 --- /dev/null +++ b/django-stubs/core/management/color.pyi @@ -0,0 +1,7 @@ +def supports_color() -> bool: ... + +class Style: ... + +def make_style(config_string: str = ...) -> Style: ... +def no_style(): ... +def color_style() -> Style: ... diff --git a/django-stubs/core/management/sql.pyi b/django-stubs/core/management/sql.pyi new file mode 100644 index 0000000..8798e12 --- /dev/null +++ b/django-stubs/core/management/sql.pyi @@ -0,0 +1,9 @@ +from typing import Any, List + +from django.core.management.color import Style + +def sql_flush( + style: Style, connection: Any, only_django: bool = ..., reset_sequences: bool = ..., allow_cascade: bool = ... +) -> List[str]: ... +def emit_pre_migrate_signal(verbosity: int, interactive: bool, db: str, **kwargs: Any) -> None: ... +def emit_post_migrate_signal(verbosity: int, interactive: bool, db: str, **kwargs: Any) -> None: ... diff --git a/django-stubs/core/management/templates.pyi b/django-stubs/core/management/templates.pyi new file mode 100644 index 0000000..8147cae --- /dev/null +++ b/django-stubs/core/management/templates.pyi @@ -0,0 +1,20 @@ +from typing import Any, Optional + +from django.core.management.base import BaseCommand, CommandParser + +class TemplateCommand(BaseCommand): + requires_system_checks: bool = ... + url_schemes: Any = ... + rewrite_template_suffixes: Any = ... + def add_arguments(self, parser: CommandParser) -> None: ... + app_or_project: Any = ... + paths_to_remove: Any = ... + verbosity: Any = ... + def handle(self, app_or_project: Any, name: Any, target: Optional[Any] = ..., **options: Any): ... + def handle_template(self, template: Any, subdir: Any): ... + def validate_name(self, name: Any, app_or_project: Any) -> None: ... + def download(self, url: Any): ... + def splitext(self, the_path: Any): ... + def extract(self, filename: Any): ... + def is_url(self, template: Any): ... + def make_writeable(self, filename: Any) -> None: ... diff --git a/django-stubs/core/management/utils.pyi b/django-stubs/core/management/utils.pyi new file mode 100644 index 0000000..27e13d3 --- /dev/null +++ b/django-stubs/core/management/utils.pyi @@ -0,0 +1,10 @@ +from typing import List, Optional, Set, Tuple, Type + +from django.apps.config import AppConfig +from django.db.models.base import Model + +def popen_wrapper(args: List[str], stdout_encoding: str = ...) -> Tuple[str, str, int]: ... +def handle_extensions(extensions: List[str]) -> Set[str]: ... +def find_command(cmd: str, path: None = ..., pathext: None = ...) -> Optional[str]: ... +def get_random_secret_key(): ... +def parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ... diff --git a/django-stubs/core/paginator.pyi b/django-stubs/core/paginator.pyi new file mode 100644 index 0000000..a286acf --- /dev/null +++ b/django-stubs/core/paginator.pyi @@ -0,0 +1,52 @@ +import collections.abc +from typing import Dict, List, Optional, Union + +from django.db.models.base import Model +from django.db.models.query import QuerySet + +class UnorderedObjectListWarning(RuntimeWarning): ... +class InvalidPage(Exception): ... +class PageNotAnInteger(InvalidPage): ... +class EmptyPage(InvalidPage): ... + +class Paginator: + object_list: QuerySet = ... + per_page: int = ... + orphans: int = ... + allow_empty_first_page: bool = ... + def __init__( + self, + object_list: Union[List[Dict[str, str]], List[Model], List[int], QuerySet, str], + per_page: Union[int, str], + orphans: int = ..., + allow_empty_first_page: bool = ..., + ) -> None: ... + def validate_number(self, number: Optional[Union[float, str]]) -> int: ... + def get_page(self, number: Optional[int]) -> Page: ... + def page(self, number: Union[int, str]) -> Page: ... + def count(self) -> int: ... + def num_pages(self) -> int: ... + @property + def page_range(self) -> range: ... + +QuerySetPaginator = Paginator + +class Page(collections.abc.Sequence): + object_list: QuerySet = ... + number: int = ... + paginator: Paginator = ... + def __init__( + self, + object_list: Union[List[Dict[str, str]], List[Model], List[int], QuerySet, str], + number: int, + paginator: Paginator, + ) -> None: ... + def __len__(self) -> int: ... + def __getitem__(self, index: Union[int, str]) -> Union[Model, str]: ... + def has_next(self) -> bool: ... + def has_previous(self) -> bool: ... + def has_other_pages(self) -> bool: ... + def next_page_number(self) -> int: ... + def previous_page_number(self) -> int: ... + def start_index(self) -> int: ... + def end_index(self) -> int: ... diff --git a/django-stubs/core/serializers/__init__.pyi b/django-stubs/core/serializers/__init__.pyi new file mode 100644 index 0000000..57c4a57 --- /dev/null +++ b/django-stubs/core/serializers/__init__.pyi @@ -0,0 +1,30 @@ +from collections import OrderedDict +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union + +from django.apps.config import AppConfig +from django.core.serializers.base import Serializer +from django.core.serializers.xml_serializer import Deserializer +from django.db.models.base import Model +from django.db.models.query import QuerySet + +BUILTIN_SERIALIZERS: Any + +class BadSerializer: + internal_use_only: bool = ... + exception: ModuleNotFoundError = ... + def __init__(self, exception: ImportError) -> None: ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... + +def register_serializer(format: str, serializer_module: str, serializers: Optional[Dict[str, Any]] = ...) -> None: ... +def unregister_serializer(format: str) -> None: ... +def get_serializer(format: str) -> Union[Type[Serializer], BadSerializer]: ... +def get_serializer_formats() -> List[str]: ... +def get_public_serializer_formats() -> List[str]: ... +def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ... +def serialize( + format: str, queryset: Union[Iterator[Any], List[Model], QuerySet], **options: Any +) -> Optional[Union[List[OrderedDict], bytes, str]]: ... +def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ... +def sort_dependencies( + app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]] +) -> List[Type[Model]]: ... diff --git a/django-stubs/core/serializers/base.pyi b/django-stubs/core/serializers/base.pyi new file mode 100644 index 0000000..1057130 --- /dev/null +++ b/django-stubs/core/serializers/base.pyi @@ -0,0 +1,84 @@ +from collections import OrderedDict +from datetime import date +from io import BufferedReader, StringIO, TextIOWrapper +from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union +from uuid import UUID + +from django.core.management.base import OutputWrapper +from django.db.models.base import Model +from django.db.models.fields.related import ForeignKey, ManyToManyField +from django.db.models.query import QuerySet + +class SerializerDoesNotExist(KeyError): ... +class SerializationError(Exception): ... + +class DeserializationError(Exception): + @classmethod + def WithData( + cls, original_exc: Exception, model: str, fk: Union[int, str], field_value: Optional[Union[List[str], str]] + ) -> DeserializationError: ... + +class M2MDeserializationError(Exception): + original_exc: Exception = ... + pk: List[str] = ... + def __init__(self, original_exc: Exception, pk: Union[List[str], str]) -> None: ... + +class ProgressBar: + progress_width: int = ... + output: None = ... + total_count: int = ... + prev_done: int = ... + def __init__(self, output: Optional[Union[StringIO, OutputWrapper]], total_count: int) -> None: ... + def update(self, count: int) -> None: ... + +class Serializer: + internal_use_only: bool = ... + progress_class: Any = ... + stream_class: Any = ... + options: Any = ... + stream: Any = ... + selected_fields: Any = ... + use_natural_foreign_keys: Any = ... + use_natural_primary_keys: Any = ... + first: bool = ... + def serialize( + self, + queryset: Union[Iterator[Any], List[Model], QuerySet], + *, + stream: Optional[Any] = ..., + fields: Optional[Any] = ..., + use_natural_foreign_keys: bool = ..., + use_natural_primary_keys: bool = ..., + progress_output: Optional[Any] = ..., + object_count: int = ..., + **options: Any + ) -> Optional[Union[List[OrderedDict], bytes, str]]: ... + def start_serialization(self) -> None: ... + def end_serialization(self) -> None: ... + def start_object(self, obj: Any) -> None: ... + def end_object(self, obj: Any) -> None: ... + def handle_field(self, obj: Any, field: Any) -> None: ... + def handle_fk_field(self, obj: Any, field: Any) -> None: ... + def handle_m2m_field(self, obj: Any, field: Any) -> None: ... + def getvalue(self) -> Optional[Union[bytes, str]]: ... + +class Deserializer: + options: Any = ... + stream: Any = ... + def __init__(self, stream_or_string: Union[BufferedReader, TextIOWrapper, str], **options: Any) -> None: ... + def __iter__(self) -> Deserializer: ... + def __next__(self) -> None: ... + +class DeserializedObject: + object: Model = ... + m2m_data: Dict[Any, Any] = ... + def __init__(self, obj: Model, m2m_data: Optional[Dict[str, List[int]]] = ...) -> None: ... + def save(self, save_m2m: bool = ..., using: Optional[str] = ..., **kwargs: Any) -> None: ... + +def build_instance(Model: Type[Model], data: Dict[str, Optional[Union[date, int, str, UUID]]], db: str) -> Model: ... +def deserialize_m2m_values( + field: ManyToManyField, field_value: Union[List[List[str]], List[int]], using: str +) -> List[int]: ... +def deserialize_fk_value( + field: ForeignKey, field_value: Optional[Union[List[str], Tuple[str], int, str]], using: str +) -> Optional[Union[int, str, UUID]]: ... diff --git a/django-stubs/core/serializers/json.pyi b/django-stubs/core/serializers/json.pyi new file mode 100644 index 0000000..6ab9f15 --- /dev/null +++ b/django-stubs/core/serializers/json.pyi @@ -0,0 +1,33 @@ +import json +from datetime import datetime +from decimal import Decimal +from io import TextIOWrapper +from typing import Any, Optional, Union, Dict, Type +from uuid import UUID + +from django.core.serializers.python import Serializer as PythonSerializer +from django.db.models.base import Model + +class Serializer(PythonSerializer): + json_kwargs: Dict[str, Optional[Type[DjangoJSONEncoder]]] + options: Dict[str, None] + selected_fields: None + stream: TextIOWrapper + use_natural_foreign_keys: bool + use_natural_primary_keys: bool + internal_use_only: bool = ... + def start_serialization(self) -> None: ... + def end_serialization(self) -> None: ... + def end_object(self, obj: Model) -> None: ... + def getvalue(self) -> Optional[Union[bytes, str]]: ... + +def Deserializer(stream_or_string: Any, **options: Any) -> None: ... + +class DjangoJSONEncoder(json.JSONEncoder): + allow_nan: bool + check_circular: bool + ensure_ascii: bool + indent: None + skipkeys: bool + sort_keys: bool + def default(self, o: Union[datetime, Decimal, UUID]) -> str: ... diff --git a/django-stubs/core/serializers/python.pyi b/django-stubs/core/serializers/python.pyi new file mode 100644 index 0000000..81963b6 --- /dev/null +++ b/django-stubs/core/serializers/python.pyi @@ -0,0 +1,40 @@ +from collections import OrderedDict +from io import TextIOWrapper +from typing import Any, Dict, Iterator, List, Optional, Union + +from django.core.serializers.base import DeserializedObject +from django.db.models.base import Model +from django.db.models.fields.related import ForeignKey, ManyToManyField + +from django.core.serializers import base +from django.db.models.fields import Field + +class Serializer(base.Serializer): + options: Dict[Any, Any] + selected_fields: None + stream: TextIOWrapper + use_natural_foreign_keys: bool + use_natural_primary_keys: bool + internal_use_only: bool = ... + objects: List[Any] = ... + def start_serialization(self) -> None: ... + def end_serialization(self) -> None: ... + def start_object(self, obj: Model) -> None: ... + def end_object(self, obj: Model) -> None: ... + def get_dump_object(self, obj: Model) -> OrderedDict: ... + def handle_field(self, obj: Model, field: Field) -> None: ... + def handle_fk_field(self, obj: Model, field: ForeignKey) -> None: ... + def handle_m2m_field(self, obj: Model, field: ManyToManyField) -> None: ... + def getvalue(self) -> List[OrderedDict]: ... + +def Deserializer( + object_list: Union[ + List[Dict[str, Optional[Union[Dict[str, Optional[str]], str]]]], + List[Dict[str, Union[Dict[str, Union[List[int], int, str]], int, str]]], + List[OrderedDict], + ], + *, + using: Any = ..., + ignorenonexistent: bool = ..., + **options: Any +) -> Iterator[DeserializedObject]: ... diff --git a/django-stubs/core/servers/__init__.pyi b/django-stubs/core/servers/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/django-stubs/core/servers/basehttp.pyi b/django-stubs/core/servers/basehttp.pyi new file mode 100644 index 0000000..493c0ac --- /dev/null +++ b/django-stubs/core/servers/basehttp.pyi @@ -0,0 +1,37 @@ +import socketserver +from io import BytesIO +from typing import Any, Dict +from wsgiref import simple_server + +from django.core.handlers.wsgi import WSGIRequest + +class WSGIServer(simple_server.WSGIServer): + request_queue_size: int = ... + address_family: Any = ... + allow_reuse_address: Any = ... + def __init__(self, *args: Any, ipv6: bool = ..., allow_reuse_address: bool = ..., **kwargs: Any) -> None: ... + def handle_error(self, request: Any, client_address: Any) -> None: ... + +class ThreadedWSGIServer(socketserver.ThreadingMixIn, WSGIServer): ... + +class ServerHandler(simple_server.ServerHandler): + http_version: str = ... + def handle_error(self) -> None: ... + +class WSGIRequestHandler(simple_server.WSGIRequestHandler): + client_address: str + close_connection: bool + connection: WSGIRequest + request: WSGIRequest + rfile: BytesIO + server: None + wfile: socketserver._SocketWriter + protocol_version: str = ... + def address_string(self) -> str: ... + def log_message(self, format: str, *args: Any) -> None: ... + def get_environ(self) -> Dict[str, str]: ... + raw_requestline: bytes = ... + requestline: str = ... + request_version: str = ... + command: None = ... + def handle(self) -> None: ... diff --git a/django-stubs/core/signing.pyi b/django-stubs/core/signing.pyi new file mode 100644 index 0000000..58258ed --- /dev/null +++ b/django-stubs/core/signing.pyi @@ -0,0 +1,48 @@ +from datetime import datetime +from typing import Any, Dict, List, Optional, Type, Union + +from django.contrib.sessions.serializers import PickleSerializer + +class BadSignature(Exception): ... +class SignatureExpired(BadSignature): ... + +def b64_encode(s: bytes) -> bytes: ... +def b64_decode(s: bytes) -> bytes: ... +def base64_hmac(salt: str, value: Union[bytes, str], key: Union[bytes, str]) -> str: ... +def get_cookie_signer(salt: str = ...) -> TimestampSigner: ... + +class JSONSerializer: + def dumps(self, obj: Union[Dict[str, Union[int, str]], List[str], str]) -> bytes: ... + def loads(self, data: bytes) -> Dict[str, Union[int, str]]: ... + +def dumps( + obj: Union[Dict[str, Union[datetime, str]], List[str], str], + key: None = ..., + salt: str = ..., + serializer: Type[Union[PickleSerializer, JSONSerializer]] = ..., + compress: bool = ..., +) -> str: ... +def loads( + s: str, + key: None = ..., + salt: str = ..., + serializer: Type[Union[PickleSerializer, JSONSerializer]] = ..., + max_age: Optional[int] = ..., +) -> Union[Dict[str, Union[datetime, str]], Dict[str, Union[int, str]], List[str], str]: ... + +class Signer: + key: str = ... + sep: str = ... + salt: Any = ... + def __init__(self, key: Optional[Union[bytes, str]] = ..., sep: str = ..., salt: Optional[str] = ...) -> None: ... + def signature(self, value: Union[bytes, str]) -> str: ... + def sign(self, value: str) -> str: ... + def unsign(self, signed_value: str) -> str: ... + +class TimestampSigner(Signer): + key: str + salt: str + sep: str + def timestamp(self) -> str: ... + def sign(self, value: str) -> str: ... + def unsign(self, value: str, max_age: Optional[int] = ...) -> str: ... diff --git a/django-stubs/core/validators.pyi b/django-stubs/core/validators.pyi new file mode 100644 index 0000000..f200942 --- /dev/null +++ b/django-stubs/core/validators.pyi @@ -0,0 +1,144 @@ +from datetime import datetime +from decimal import Decimal +from re import RegexFlag +from typing import Any, Dict, List, Optional, Union +from uuid import UUID + +from django.core.files.base import File +from django.utils.functional import SimpleLazyObject + +EMPTY_VALUES: Any + +class RegexValidator: + regex: SimpleLazyObject = ... + message: Any = ... + code: str = ... + inverse_match: bool = ... + flags: int = ... + def __init__( + self, + regex: Optional[str] = ..., + message: Optional[str] = ..., + code: Optional[str] = ..., + inverse_match: Optional[bool] = ..., + flags: Optional[RegexFlag] = ..., + ) -> None: ... + def __call__(self, value: Optional[Union[float, str]]) -> None: ... + def __eq__(self, other: Union[ProhibitNullCharactersValidator, RegexValidator]) -> bool: ... + +class URLValidator(RegexValidator): + ul: str = ... + ipv4_re: str = ... + ipv6_re: str = ... + hostname_re: Any = ... + domain_re: Any = ... + tld_re: Any = ... + host_re: Any = ... + regex: SimpleLazyObject = ... + message: Any = ... + schemes: Any = ... + def __init__(self, schemes: Optional[List[str]] = ..., **kwargs: Any) -> None: ... + def __call__(self, value: str) -> None: ... + +integer_validator: Any + +def validate_integer(value: Optional[Union[float, str]]) -> None: ... + +class EmailValidator: + message: Any = ... + code: str = ... + user_regex: Any = ... + domain_regex: Any = ... + literal_regex: Any = ... + domain_whitelist: Any = ... + def __init__( + self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[List[str]] = ... + ) -> None: ... + def __call__(self, value: Optional[str]) -> None: ... + def validate_domain_part(self, domain_part: str) -> bool: ... + def __eq__(self, other: EmailValidator) -> bool: ... + +validate_email: Any +slug_re: Any +validate_slug: Any +slug_unicode_re: Any +validate_unicode_slug: Any + +def validate_ipv4_address(value: str) -> None: ... +def validate_ipv6_address(value: str) -> None: ... +def validate_ipv46_address(value: str) -> None: ... + +ip_address_validator_map: Any + +def ip_address_validators(protocol: str, unpack_ipv4: bool) -> Any: ... +def int_list_validator( + sep: str = ..., message: None = ..., code: str = ..., allow_negative: bool = ... +) -> RegexValidator: ... + +validate_comma_separated_integer_list: Any + +class BaseValidator: + message: Any = ... + code: str = ... + limit_value: bool = ... + def __init__( + self, limit_value: Optional[Union[datetime, Decimal, float, str]], message: Optional[str] = ... + ) -> None: ... + def __call__(self, value: Union[bytes, datetime, Decimal, float, str]) -> None: ... + def __eq__(self, other: BaseValidator) -> bool: ... + def compare(self, a: bool, b: bool) -> bool: ... + def clean(self, x: Union[datetime, Decimal, float]) -> Union[datetime, Decimal, float]: ... + +class MaxValueValidator(BaseValidator): + limit_value: Decimal + message: Any = ... + code: str = ... + def compare(self, a: Union[datetime, Decimal, float], b: Union[datetime, Decimal, float]) -> bool: ... + +class MinValueValidator(BaseValidator): + limit_value: int + message: Any = ... + code: str = ... + def compare(self, a: Union[datetime, Decimal, float], b: Union[datetime, Decimal, float]) -> bool: ... + +class MinLengthValidator(BaseValidator): + limit_value: int + message: Any = ... + code: str = ... + def compare(self, a: int, b: int) -> bool: ... + def clean(self, x: str) -> int: ... + +class MaxLengthValidator(BaseValidator): + limit_value: int + message: Any = ... + code: str = ... + def compare(self, a: int, b: int) -> bool: ... + def clean(self, x: Union[bytes, str]) -> int: ... + +class DecimalValidator: + messages: Any = ... + max_digits: int = ... + decimal_places: int = ... + def __init__(self, max_digits: Optional[Union[int, str]], decimal_places: Optional[Union[int, str]]) -> None: ... + def __call__(self, value: Decimal) -> None: ... + def __eq__(self, other: Union[DecimalValidator, MinValueValidator]) -> bool: ... + +class FileExtensionValidator: + message: Any = ... + code: str = ... + allowed_extensions: List[str] = ... + def __init__( + self, allowed_extensions: Optional[List[str]] = ..., message: Optional[str] = ..., code: Optional[str] = ... + ) -> None: ... + def __call__(self, value: File) -> None: ... + def __eq__(self, other: FileExtensionValidator) -> bool: ... + +def get_available_image_extensions() -> List[str]: ... +def validate_image_file_extension(value: File) -> None: ... + +class ProhibitNullCharactersValidator: + message: Any = ... + code: str = ... + def __init__(self, message: Optional[str] = ..., code: Optional[str] = ...) -> None: ... + def __call__(self, value: Optional[Union[Dict[Any, Any], str, UUID]]) -> None: ... + def __eq__(self, other: Union[ProhibitNullCharactersValidator, RegexValidator]) -> bool: ... diff --git a/django-stubs/core/wsgi.pyi b/django-stubs/core/wsgi.pyi new file mode 100644 index 0000000..ac5938a --- /dev/null +++ b/django-stubs/core/wsgi.pyi @@ -0,0 +1,3 @@ +from django.core.handlers.wsgi import WSGIHandler + +def get_wsgi_application() -> WSGIHandler: ... diff --git a/django-stubs/db/migrations/operations/models.pyi b/django-stubs/db/migrations/operations/models.pyi index f0282a4..9d116c5 100644 --- a/django-stubs/db/migrations/operations/models.pyi +++ b/django-stubs/db/migrations/operations/models.pyi @@ -60,7 +60,7 @@ class AlterOrderWithRespectTo(FieldRelatedOptionOperation): class AlterModelOptions(ModelOptionOperation): ALTER_OPTION_KEYS: Any = ... options: Dict[str, str] = ... - def __init__(self, name: str, options: Dict[str, str]) -> None: ... + def __init__(self, name: str, options: Dict[str, Any]) -> None: ... class AlterModelManagers(ModelOptionOperation): serialization_expand_args: Any = ... diff --git a/django-stubs/db/migrations/recorder.pyi b/django-stubs/db/migrations/recorder.pyi index 655f30d..99ac579 100644 --- a/django-stubs/db/migrations/recorder.pyi +++ b/django-stubs/db/migrations/recorder.pyi @@ -1,11 +1,9 @@ from typing import Any, Optional, Set, Tuple, Union -from django.db import DefaultConnectionProxy, models +from django.db import 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 = ... @@ -15,8 +13,8 @@ class MigrationRecorder: apps: Any = ... app_label: str = ... db_table: str = ... - connection: Any = ... - def __init__(self, connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]]) -> None: ... + connection: Optional[BaseDatabaseWrapper] = ... + def __init__(self, connection: Optional[BaseDatabaseWrapper]) -> None: ... @property def migration_qs(self) -> QuerySet: ... def has_table(self) -> bool: ... diff --git a/django-stubs/db/models/__init__.pyi b/django-stubs/db/models/__init__.pyi index 81aca44..c20a501 100644 --- a/django-stubs/db/models/__init__.pyi +++ b/django-stubs/db/models/__init__.pyi @@ -11,6 +11,7 @@ from .fields import ( BigIntegerField as BigIntegerField, CharField as CharField, EmailField as EmailField, + URLField as URLField, Field as Field, SlugField as SlugField, TextField as TextField, diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 9c87c7f..cdc6b61 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -3,7 +3,7 @@ from typing import Any, Optional from django.db.models.query_utils import RegisterLookupMixin class Field(RegisterLookupMixin): - def __init__(self, primary_key: bool = False, **kwargs): ... + def __init__(self, **kwargs: Any): ... def __get__(self, instance, owner) -> Any: ... class IntegerField(Field): @@ -21,12 +21,13 @@ class AutoField(Field): def __get__(self, instance, owner) -> int: ... class CharField(Field): - def __init__(self, max_length: int, **kwargs): ... + def __init__(self, max_length: int, **kwargs: Any): ... def __set__(self, instance, value: str) -> None: ... def __get__(self, instance, owner) -> str: ... class SlugField(CharField): ... class EmailField(CharField): ... +class URLField(CharField): ... class TextField(Field): def __set__(self, instance, value: str) -> None: ... @@ -53,7 +54,6 @@ class GenericIPAddressField(Field): name: Optional[Any] = ..., protocol: str = ..., unpack_ipv4: bool = ..., - *args: Any, **kwargs: Any ) -> None: ... diff --git a/django-stubs/db/models/query.pyi b/django-stubs/db/models/query.pyi index 9db2bbd..bb3f3c4 100644 --- a/django-stubs/db/models/query.pyi +++ b/django-stubs/db/models/query.pyi @@ -1,6 +1,6 @@ -from collections import OrderedDict -from datetime import date, datetime -from typing import TypeVar, Optional, Any, Type, Dict, Union, overload, List, Iterator, Tuple, Callable, Iterable, Sized +from typing import TypeVar, Optional, Any, Type, Dict, Union, overload, List, Iterator, Tuple, Iterable, Sized, Sequence + +from django.db.models.base import Model from django.db import models from django.db.models import Manager @@ -31,20 +31,12 @@ class QuerySet(Iterable[_T], Sized): def __and__(self, other: QuerySet) -> QuerySet: ... def __or__(self, other: QuerySet) -> QuerySet: ... def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ... - def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Optional[Union[datetime, float]]]: ... + def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... def get(self, *args: Any, **kwargs: Any) -> _T: ... def create(self, **kwargs: Any) -> _T: ... - def bulk_create( - self, objs: Union[Iterator[Any], List[models.Model]], batch_size: Optional[int] = ... - ) -> List[_T]: ... - def get_or_create( - self, defaults: Optional[Union[Dict[str, date], Dict[str, models.Model]]] = ..., **kwargs: Any - ) -> Tuple[_T, bool]: ... - def update_or_create( - self, - defaults: Optional[Union[Dict[str, Callable], Dict[str, date], Dict[str, models.Model], Dict[str, str]]] = ..., - **kwargs: Any - ) -> Tuple[_T, bool]: ... + def bulk_create(self, objs: Sequence[Model], batch_size: Optional[int] = ...) -> List[_T]: ... + def get_or_create(self, defaults: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... + def update_or_create(self, defaults: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... def first(self) -> Optional[_T]: ... @@ -80,12 +72,12 @@ class QuerySet(Iterable[_T], Sized): def distinct(self, *field_names: Any) -> QuerySet[_T]: ... def extra( self, - select: Optional[Union[Dict[str, int], Dict[str, str], OrderedDict]] = ..., + select: Optional[Dict[str, Any]] = ..., where: Optional[List[str]] = ..., - params: Optional[Union[List[int], List[str]]] = ..., + params: Optional[List[Any]] = ..., tables: Optional[List[str]] = ..., - order_by: Optional[Union[List[str], Tuple[str]]] = ..., - select_params: Optional[Union[List[int], List[str], Tuple[int]]] = ..., + order_by: Optional[Sequence[str]] = ..., + select_params: Optional[Sequence[Any]] = ..., ) -> QuerySet[_T]: ... def reverse(self) -> QuerySet[_T]: ... def defer(self, *fields: Any) -> QuerySet[_T]: ... diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index 769accc..8305669 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -66,7 +66,6 @@ class HttpResponse(HttpResponseBase): 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 @@ -92,11 +91,14 @@ class HttpResponse(HttpResponseBase): def writelines(self, lines: List[str]) -> None: ... @property def url(self) -> str: ... + def json(self) -> Dict[str, Any]: ... class StreamingHttpResponse(HttpResponseBase): def __init__(self, streaming_content: Iterable[bytes] = ..., *args: Any, **kwargs: Any) -> None: ... @property def content(self) -> bytes: ... + @content.setter + def content(self, value: Any) -> None: ... @property def streaming_content(self) -> Iterator[bytes]: ... @streaming_content.setter @@ -110,7 +112,6 @@ class FileResponse(StreamingHttpResponse): context: None cookies: cookies.SimpleCookie file_to_stream: Optional[BytesIO] - json: Callable[[], Dict] request: Dict[str, str] resolver_match: ResolverMatch templates: List[Any] @@ -120,6 +121,7 @@ class FileResponse(StreamingHttpResponse): filename: str = ... def __init__(self, *args: Any, as_attachment: bool = ..., filename: str = ..., **kwargs: Any) -> None: ... def set_headers(self, filelike: BytesIO) -> None: ... + def json(self) -> Dict[str, Any]: ... class HttpResponseRedirectBase(HttpResponse): allowed_schemes = ... # type: List[str]