Add test to import all modules to check validity of stubs (#56)

* add import_all.test builder

* fix errors

* fix typechecking errors

* fix migrations typechecking
This commit is contained in:
Maxim Kurnikov
2019-03-25 01:57:34 +03:00
committed by GitHub
parent 5d0ee40ada
commit 5c6be7ad12
79 changed files with 706 additions and 1155 deletions
+17 -10
View File
@@ -1,9 +1,16 @@
from typing import Any, Callable, Dict, Iterator, List, Optional
from django.db.backends.base.client import BaseDatabaseClient
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.base.validation import BaseDatabaseValidation
from django.db.backends.utils import CursorDebugWrapper, CursorWrapper
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.backends.base.introspection import BaseDatabaseIntrospection
NO_DB_ALIAS: str
class BaseDatabaseWrapper:
@@ -23,7 +30,7 @@ class BaseDatabaseWrapper:
queries_limit: int = ...
connection: Any = ...
settings_dict: Any = ...
alias: Any = ...
alias: str = ...
queries_log: Any = ...
force_debug_cursor: bool = ...
autocommit: bool = ...
@@ -32,18 +39,18 @@ class BaseDatabaseWrapper:
savepoint_ids: Any = ...
commit_on_exit: bool = ...
needs_rollback: bool = ...
close_at: Any = ...
close_at: Optional[Any] = ...
closed_in_transaction: bool = ...
errors_occurred: bool = ...
allow_thread_sharing: Any = ...
run_on_commit: Any = ...
allow_thread_sharing: bool = ...
run_on_commit: List[Any] = ...
run_commit_hooks_on_set_autocommit_on: bool = ...
execute_wrappers: Any = ...
client: Any = ...
creation: Any = ...
features: Any = ...
introspection: Any = ...
validation: Any = ...
execute_wrappers: List[Any] = ...
client: BaseDatabaseClient = ...
creation: BaseDatabaseCreation = ...
features: BaseDatabaseFeatures = ...
introspection: BaseDatabaseIntrospection = ...
validation: BaseDatabaseValidation = ...
def __init__(
self, settings_dict: Dict[str, Dict[str, str]], alias: str = ..., allow_thread_sharing: bool = ...
) -> None: ...
+11 -10
View File
@@ -1,13 +1,14 @@
from typing import Any, List, Optional, Tuple, Type, Union
from typing import Any, ContextManager, List, Optional, Sequence, Tuple, Type, Union
from django.db.backends.ddl_references import Statement
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.fields import Field
logger: Any
class BaseDatabaseSchemaEditor:
class BaseDatabaseSchemaEditor(ContextManager[Any]):
sql_create_table: str = ...
sql_rename_table: str = ...
sql_retablespace_table: str = ...
@@ -27,7 +28,7 @@ class BaseDatabaseSchemaEditor:
sql_create_unique: str = ...
sql_delete_unique: str = ...
sql_create_fk: str = ...
sql_create_inline_fk: Any = ...
sql_create_inline_fk: str = ...
sql_delete_fk: str = ...
sql_create_index: str = ...
sql_delete_index: str = ...
@@ -35,14 +36,14 @@ class BaseDatabaseSchemaEditor:
sql_delete_pk: str = ...
sql_delete_procedure: str = ...
connection: Any = ...
collect_sql: Any = ...
collect_sql: bool = ...
collected_sql: Any = ...
atomic_migration: Any = ...
def __init__(self, connection: Any, collect_sql: bool = ..., atomic: bool = ...) -> None: ...
deferred_sql: Any = ...
atomic: Any = ...
def __enter__(self) -> BaseDatabaseSchemaEditor: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: ...
def execute(self, sql: Union[Statement, str], params: Optional[Union[List[int], Tuple]] = ...) -> None: ...
def quote_name(self, name: str) -> str: ...
def column_sql(
@@ -59,14 +60,14 @@ class BaseDatabaseSchemaEditor:
def alter_unique_together(
self,
model: Type[Model],
old_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]],
new_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]],
old_unique_together: Sequence[Sequence[str]],
new_unique_together: Sequence[Sequence[str]],
) -> None: ...
def alter_index_together(
self,
model: Type[Model],
old_index_together: Union[List[List[str]], List[Tuple[str, str]]],
new_index_together: Union[List[List[str]], List[Tuple[str, str]]],
old_index_together: Sequence[Sequence[str]],
new_index_together: Sequence[Sequence[str]],
) -> None: ...
def alter_db_table(self, model: Type[Model], old_db_table: str, new_db_table: str) -> None: ...
def alter_db_tablespace(self, model: Any, old_db_tablespace: Any, new_db_tablespace: Any) -> None: ...
+1 -35
View File
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.base.client import BaseDatabaseClient
@@ -10,20 +10,16 @@ def complain(*args: Any, **kwargs: Any) -> Any: ...
def ignore(*args: Any, **kwargs: Any) -> None: ...
class DatabaseOperations(BaseDatabaseOperations):
connection: django.db.backends.dummy.base.DatabaseWrapper
quote_name: Any = ...
class DatabaseClient(BaseDatabaseClient):
connection: django.db.backends.dummy.base.DatabaseWrapper
runshell: Any = ...
class DatabaseCreation(BaseDatabaseCreation):
connection: django.db.backends.dummy.base.DatabaseWrapper
create_test_db: Any = ...
destroy_test_db: Any = ...
class DatabaseIntrospection(BaseDatabaseIntrospection):
connection: django.db.backends.dummy.base.DatabaseWrapper
get_table_list: Any = ...
get_table_description: Any = ...
get_relations: Any = ...
@@ -31,35 +27,5 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
get_key_columns: Any = ...
class DatabaseWrapper(BaseDatabaseWrapper):
alias: str
allow_thread_sharing: bool
autocommit: bool
client: django.db.backends.dummy.base.DatabaseClient
close_at: None
closed_in_transaction: bool
commit_on_exit: bool
connection: None
creation: django.db.backends.dummy.base.DatabaseCreation
errors_occurred: bool
execute_wrappers: List[Any]
features: django.db.backends.dummy.features.DummyDatabaseFeatures
force_debug_cursor: bool
in_atomic_block: bool
introspection: django.db.backends.dummy.base.DatabaseIntrospection
needs_rollback: bool
ops: django.db.backends.dummy.base.DatabaseOperations
queries_log: collections.deque
run_commit_hooks_on_set_autocommit_on: bool
run_on_commit: List[Any]
savepoint_ids: List[Any]
savepoint_state: int
settings_dict: Dict[str, Optional[Union[Dict[str, None], int, str]]]
validation: django.db.backends.base.validation.BaseDatabaseValidation
operators: Any = ...
ensure_connection: Any = ...
client_class: Any = ...
creation_class: Any = ...
features_class: Any = ...
introspection_class: Any = ...
ops_class: Any = ...
def is_usable(self): ...
+1 -23
View File
@@ -1,25 +1,3 @@
from typing import Any, Optional, Type, Union
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.models.base import Model
from django.db.models.fields import Field
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
atomic_migration: bool
collect_sql: bool
connection: Any
sql_delete_table: str = ...
sql_create_fk: Any = ...
sql_create_inline_fk: str = ...
sql_create_unique: str = ...
sql_delete_unique: str = ...
def __enter__(self) -> DatabaseSchemaEditor: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def quote_value(self, value: Optional[Union[int, str]]) -> str: ...
def alter_db_table(
self, model: Type[Model], old_db_table: str, new_db_table: str, disable_constraints: bool = ...
) -> None: ...
def alter_field(self, model: Type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ...
def delete_model(self, model: Type[Model], handle_autom2m: bool = ...) -> None: ...
def add_field(self, model: Type[Model], field: Field) -> None: ...
def remove_field(self, model: Type[Model], field: Field) -> None: ...
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): ...
+4 -12
View File
@@ -1,11 +1,8 @@
from typing import Any, Dict, Optional, Sequence, Set, Tuple, Union
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.migrations.migration import Migration, SwappableTuple
from django.db.migrations.migration import Migration
from django.db.migrations.state import ProjectState
from django.db import DefaultConnectionProxy
MIGRATIONS_MODULE_NAME: str
class MigrationLoader:
@@ -13,12 +10,7 @@ class MigrationLoader:
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: ...
def __init__(self, connection: Any, load: bool = ..., ignore_no_migrations: bool = ...) -> None: ...
@classmethod
def migrations_module(cls, app_label: str) -> Tuple[Optional[str], bool]: ...
unmigrated_apps: Set[str] = ...
@@ -26,7 +18,7 @@ class MigrationLoader:
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 check_key(self, key: Tuple[str, str], 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 = ...
@@ -35,5 +27,5 @@ class MigrationLoader:
def check_consistent_history(self, connection: Any) -> None: ...
def detect_conflicts(self) -> Dict[str, Set[str]]: ...
def project_state(
self, nodes: Optional[Tuple[str, str], Sequence[Tuple[str, str]]] = ..., at_end: bool = ...
self, nodes: Optional[Union[Tuple[str, str], Sequence[Tuple[str, str]]]] = ..., at_end: bool = ...
) -> ProjectState: ...
+1 -1
View File
@@ -21,7 +21,7 @@ class Migration:
self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ...
) -> ProjectState: ...
class SwappableTuple(tuple):
class SwappableTuple(Tuple[str, str]):
setting: str = ...
def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ...