Add missing type for setup_databases (#919)

* Add missing type for setup_databases

`django.test.utils` was seemingly missing the type for `setup_databases`. 

This change resolves my issue locally. The type was copied directly from `django.test.runner`.

* Fix typecheck_tests runner

Co-authored-by: Xavier Francisco <xavier.n.francisco@gmail.com>
This commit is contained in:
Xavier Francisco
2022-04-13 09:56:57 +00:00
committed by GitHub
parent e468ee97da
commit 40bf7a562d
2 changed files with 18 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ from typing import (
List, List,
Mapping, Mapping,
Optional, Optional,
Protocol,
Set, Set,
Tuple, Tuple,
Type, Type,
@@ -139,12 +140,28 @@ def tag(*tags: str): ...
_Signature = str _Signature = str
_TestDatabase = Tuple[str, List[str]] _TestDatabase = Tuple[str, List[str]]
class TimeKeeperProtocol(Protocol):
@contextmanager
def timed(self, name: Any) -> Iterator[None]: ...
def print_results(self) -> None: ...
def dependency_ordered( def dependency_ordered(
test_databases: Iterable[Tuple[_Signature, _TestDatabase]], dependencies: Mapping[str, List[str]] test_databases: Iterable[Tuple[_Signature, _TestDatabase]], dependencies: Mapping[str, List[str]]
) -> List[Tuple[_Signature, _TestDatabase]]: ... ) -> List[Tuple[_Signature, _TestDatabase]]: ...
def get_unique_databases_and_mirrors( def get_unique_databases_and_mirrors(
aliases: Optional[Set[str]] = ..., aliases: Optional[Set[str]] = ...,
) -> Tuple[Dict[_Signature, _TestDatabase], Dict[str, Any]]: ... ) -> Tuple[Dict[_Signature, _TestDatabase], Dict[str, Any]]: ...
def setup_databases(
verbosity: int,
interactive: bool,
*,
time_keeper: Optional[TimeKeeperProtocol] = ...,
keepdb: bool = ...,
debug_sql: bool = ...,
parallel: int = ...,
aliases: Optional[Mapping[str, Any]] = ...,
**kwargs: Any
) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ...
def teardown_databases( def teardown_databases(
old_config: Iterable[Tuple[Any, str, bool]], verbosity: int, parallel: int = ..., keepdb: bool = ... old_config: Iterable[Tuple[Any, str, bool]], verbosity: int, parallel: int = ..., keepdb: bool = ...
) -> None: ... ) -> None: ...

View File

@@ -28,4 +28,4 @@ def checkout_django_branch(django_version: str, commit_sha: Optional[str]) -> Re
) )
if commit_sha and repo.head.commit.hexsha != commit_sha: if commit_sha and repo.head.commit.hexsha != commit_sha:
repo.remote("origin").fetch(branch, progress=ProgressPrinter(), depth=100) repo.remote("origin").fetch(branch, progress=ProgressPrinter(), depth=100)
repo.git.checkout(commit_sha) repo.git.checkout(branch)