Add stubs for remaining commands in django.core.management.commands (#525)

* Add stubs for remaining commands in django.core.management.commands

* Tighten up stub definitions in django.core.management.commands

* Apply some missing declarations in django.core.management.commands
This commit is contained in:
Tim Martin
2020-11-10 22:56:41 +00:00
committed by GitHub
parent 01af2ff588
commit e798b496c0
22 changed files with 198 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
from django.apps import apps as apps
from django.core import checks as checks
from django.core.checks.registry import registry as registry
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from typing import Any, List
class Command(BaseCommand):
def handle(self, *app_labels: List[str], **options: Any) -> None: ...

View File

@@ -0,0 +1,16 @@
import os
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError, CommandParser as CommandParser
from django.core.management.utils import find_command as find_command, popen_wrapper as popen_wrapper
from typing import List, Tuple, Union
_PathType = Union[str, bytes, os.PathLike]
def has_bom(fn: _PathType) -> bool: ...
def is_writable(path: _PathType) -> bool: ...
class Command(BaseCommand):
program: str = ...
program_options: List[str] = ...
verbosity: int = ...
has_errors: bool = ...
def compile_messages(self, locations: List[Tuple[_PathType, _PathType]]) -> None: ...

View File

@@ -0,0 +1,11 @@
from django.conf import settings as settings
from django.core.cache import caches as caches
from django.core.cache.backends.db import BaseDatabaseCache as BaseDatabaseCache
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, DatabaseError as DatabaseError, connections as connections, models as models, router as router, transaction as transaction
from typing import Any, List
class Command(BaseCommand):
verbosity: int = ...
def handle(self, *tablenames: List[str], **options: Any) -> None: ...
def create_table(self, database: str, tablename: str, dry_run: bool) -> None: ...

View File

@@ -0,0 +1,4 @@
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError, CommandParser as CommandParser
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
class Command(BaseCommand): ...

View File

@@ -0,0 +1,8 @@
from django.core.management.base import BaseCommand as BaseCommand
from typing import Any, Callable, Dict, List
def module_to_dict(module: Any, omittable: Callable[[str], bool] = ...) -> Dict[str, str]: ...
class Command(BaseCommand):
def output_hash(self, user_settings: Dict[str, str], default_settings: Dict[str, str], **options: Any) -> List[str]: ...
def output_unified(self, user_settings: Dict[str, str], default_settings: Dict[str, str], **options: Any) -> List[str]: ...

View File

@@ -0,0 +1,10 @@
from django.apps import apps as apps
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from django.core.management.color import Style, no_style as no_style
from django.core.management.sql import emit_post_migrate_signal as emit_post_migrate_signal, sql_flush as sql_flush
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
from typing import Tuple
class Command(BaseCommand):
stealth_options: Tuple[str] = ...
style: Style = ...

View File

@@ -0,0 +1,12 @@
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
from django.db.models.constants import LOOKUP_SEP as LOOKUP_SEP
from typing import Any, Dict, Iterable, List, Tuple
class Command(BaseCommand):
stealth_options: Tuple[str] = ...
db_module: str = ...
def handle_inspection(self, options: Dict[str, Any]) -> Iterable[str]: ...
def normalize_col_name(self, col_name: str, used_column_names: List[str], is_relation: bool) -> Tuple[str, Dict[str, str], List[str]]: ...
def get_field_type(self, connection: Any, table_name: Any, row: Any) -> Tuple[str, Dict[str, str], List[str]]: ...
def get_meta(self, table_name: str, constraints: Any, column_to_field_name: Any, is_view: Any, is_partition: Any) -> List[str]: ...

View File

@@ -0,0 +1,23 @@
from django.apps import apps as apps
from django.conf import settings as settings
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError, no_translations as no_translations
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, OperationalError as OperationalError, connections as connections, router as router
from django.db.migrations import Migration as Migration
from django.db.migrations.autodetector import MigrationAutodetector as MigrationAutodetector
from django.db.migrations.loader import MigrationLoader as MigrationLoader
from django.db.migrations.questioner import InteractiveMigrationQuestioner as InteractiveMigrationQuestioner, MigrationQuestioner as MigrationQuestioner, NonInteractiveMigrationQuestioner as NonInteractiveMigrationQuestioner
from django.db.migrations.state import ProjectState as ProjectState
from django.db.migrations.utils import get_migration_name_timestamp as get_migration_name_timestamp
from django.db.migrations.writer import MigrationWriter as MigrationWriter
from typing import Any, Dict
class Command(BaseCommand):
verbosity: int = ...
interactive: bool = ...
dry_run: bool = ...
merge: bool = ...
empty: bool = ...
migration_name: str = ...
include_header: bool = ...
def write_migration_files(self, changes: Dict[str, Any]) -> None: ...
def handle_merge(self, loader: MigrationLoader, conflicts: Dict[str, Any]) -> None: ...

View File

@@ -0,0 +1,21 @@
from django.apps import apps as apps
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError, no_translations as no_translations
from django.core.management.sql import emit_post_migrate_signal as emit_post_migrate_signal, emit_pre_migrate_signal as emit_pre_migrate_signal
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections, router as router
from django.db.migrations.autodetector import MigrationAutodetector as MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor as MigrationExecutor
from django.db.migrations.loader import AmbiguityError as AmbiguityError
from django.db.migrations.operations.base import Operation
from django.db.migrations.state import ModelState as ModelState, ProjectState as ProjectState
from django.utils.module_loading import module_has_submodule as module_has_submodule
from django.utils.text import Truncator as Truncator
from typing import Any, List, Optional
class Command(BaseCommand):
verbosity: int = ...
interactive: bool = ...
start: float = ...
def migration_progress_callback(self, action: str, migration: Optional[Any] = ..., fake: bool = ...) -> None: ...
def sync_apps(self, connection: Any, app_labels: List[str]) -> None: ...
@staticmethod
def describe_operation(operation: Operation, backwards: bool) -> str: ...

View File

@@ -0,0 +1,6 @@
from django.core.mail import mail_admins as mail_admins, mail_managers as mail_managers, send_mail as send_mail
from django.core.management.base import BaseCommand as BaseCommand
from django.utils import timezone as timezone
class Command(BaseCommand):
missing_args_message: str = ...

View File

@@ -0,0 +1,9 @@
from django.core.management import BaseCommand as BaseCommand, CommandError as CommandError
from django.utils.datastructures import OrderedSet as OrderedSet
from typing import Any, List
class Command(BaseCommand):
shells: List[str] = ...
def ipython(self, options: Any) -> None: ...
def bpython(self, options: Any) -> None: ...
def python(self, options: Any) -> None: ...

View File

@@ -0,0 +1,10 @@
from django.apps import apps as apps
from django.core.management.base import BaseCommand as BaseCommand
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
from django.db.migrations.loader import MigrationLoader as MigrationLoader
from typing import Any, List, Optional
class Command(BaseCommand):
verbosity: int = ...
def show_list(self, connection: Any, app_names: Optional[List[str]] = ...) -> None: ...
def show_plan(self, connection: Any, app_names: Optional[List[str]] = ...) -> None: ...

View File

@@ -0,0 +1,6 @@
from django.core.management.base import BaseCommand as BaseCommand
from django.core.management.sql import sql_flush as sql_flush
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
class Command(BaseCommand):
output_transaction: bool = ...

View File

@@ -0,0 +1,9 @@
from django.apps import apps as apps
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
from django.db.migrations.loader import AmbiguityError as AmbiguityError, MigrationLoader as MigrationLoader
from typing import Any
class Command(BaseCommand):
output_transaction: bool = ...
def execute(self, *args: Any, **options: Any): ...

View File

@@ -0,0 +1,4 @@
from django.core.management.base import AppCommand as AppCommand
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections
class Command(AppCommand): ...

View File

@@ -0,0 +1,15 @@
from django.apps import apps as apps
from django.conf import settings as settings
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from django.db import DEFAULT_DB_ALIAS as DEFAULT_DB_ALIAS, connections as connections, migrations as migrations
from django.db.migrations.migration import Migration
from django.db.migrations.loader import AmbiguityError as AmbiguityError, MigrationLoader as MigrationLoader
from django.db.migrations.migration import SwappableTuple as SwappableTuple
from django.db.migrations.optimizer import MigrationOptimizer as MigrationOptimizer
from django.db.migrations.writer import MigrationWriter as MigrationWriter
from django.utils.version import get_docs_version as get_docs_version
class Command(BaseCommand):
verbosity: int = ...
interactive: bool = ...
def find_migration(self, loader: MigrationLoader, app_label: str, name: str) -> Migration: ...

View File

@@ -0,0 +1,5 @@
from django.core.management.templates import TemplateCommand as TemplateCommand
from typing import Any
class Command(TemplateCommand):
missing_args_message: str = ...

View File

@@ -0,0 +1,5 @@
from ..utils import get_random_secret_key as get_random_secret_key
from django.core.management.templates import TemplateCommand as TemplateCommand
class Command(TemplateCommand):
missing_args_message: str = ...

View File

@@ -0,0 +1,10 @@
from django.conf import settings as settings
from django.core.management.base import BaseCommand as BaseCommand
from django.core.management.utils import get_command_line_option as get_command_line_option
from django.test.utils import get_runner as get_runner
from typing import Any
class Command(BaseCommand):
test_runner: Any = ...
def run_from_argv(self, argv: Any) -> None: ...
def add_arguments(self, parser: Any) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import List, Optional, Set, Tuple, Type from typing import Any, List, Optional, Set, Tuple, Type
from django.apps.config import AppConfig from django.apps.config import AppConfig
from django.db.models.base import Model from django.db.models.base import Model
@@ -8,3 +8,4 @@ def handle_extensions(extensions: List[str]) -> Set[str]: ...
def find_command(cmd: str, path: Optional[str] = ..., pathext: Optional[str] = ...) -> Optional[str]: ... def find_command(cmd: str, path: Optional[str] = ..., pathext: Optional[str] = ...) -> Optional[str]: ...
def get_random_secret_key(): ... def get_random_secret_key(): ...
def parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ... def parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ...
def get_command_line_option(argv: Any, option: Any): ...

View File

@@ -3,6 +3,8 @@ from typing import Any, Dict, Optional, Sequence, Set, Tuple, Union
from django.db.migrations.migration import Migration from django.db.migrations.migration import Migration
from django.db.migrations.state import ProjectState from django.db.migrations.state import ProjectState
from .exceptions import AmbiguityError as AmbiguityError, BadMigrationError as BadMigrationError, InconsistentMigrationHistory as InconsistentMigrationHistory, NodeNotFoundError as NodeNotFoundError
MIGRATIONS_MODULE_NAME: str MIGRATIONS_MODULE_NAME: str
class MigrationLoader: class MigrationLoader:

View File

@@ -10,8 +10,8 @@ class Operation:
def state_forwards(self, app_label: Any, state: Any) -> 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_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 database_backwards(self, app_label: Any, schema_editor: Any, from_state: Any, to_state: Any) -> None: ...
def describe(self): ... def describe(self) -> str: ...
def references_model(self, name: str, app_label: str = ...) -> bool: ... def references_model(self, name: str, app_label: str = ...) -> bool: ...
def references_field(self, model_name: str, 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 allow_migrate_model(self, connection_alias: Any, model: Any) -> bool: ...
def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ... def reduce(self, operation: Operation, in_between: List[Operation], app_label: str = ...) -> bool: ...