Provide a more specific signature for django.core.checks.register (#509)

This also corrects the fact that "run_checks" only returns a concatenated list
of all registered check results, which may only contain CheckMessage:
302caa40e4/django/core/checks/registry.py (L60)
This commit is contained in:
Brian Helba
2020-10-29 03:31:26 -04:00
committed by GitHub
parent 6dc2c32382
commit a3624dec36

View File

@@ -15,17 +15,19 @@ class Tags:
translation: str = ... translation: str = ...
urls: str = ... urls: str = ...
_CheckCallable = Callable[..., List[CheckMessage]]
class CheckRegistry: class CheckRegistry:
registered_checks: Set[Callable] = ... registered_checks: Set[Callable] = ...
deployment_checks: Set[Callable] = ... deployment_checks: Set[Callable] = ...
def __init__(self) -> None: ... def __init__(self) -> None: ...
def register(self, check: Optional[Union[Callable, str]] = ..., *tags: Any, **kwargs: Any) -> Callable: ... def register(self, check: Optional[Union[_CheckCallable, str]] = ..., *tags: str, **kwargs: Any) -> Callable: ...
def run_checks( def run_checks(
self, self,
app_configs: Optional[List[AppConfig]] = ..., app_configs: Optional[List[AppConfig]] = ...,
tags: Optional[List[str]] = ..., tags: Optional[List[str]] = ...,
include_deployment_checks: bool = ..., include_deployment_checks: bool = ...,
) -> Union[List[CheckMessage], List[int], List[str]]: ... ) -> List[CheckMessage]: ...
def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ... def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ...
def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ... def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ...
def get_checks(self, include_deployment_checks: bool = ...) -> List[Callable]: ... def get_checks(self, include_deployment_checks: bool = ...) -> List[Callable]: ...