Ensure that all registered checks take the same parameters (#499)

The Django API requires that registered checks take an "app_configs"
argument, which is a list of AppConfig. This is practically also passed by
keyword, so all parameters should be specified with a "= ..." to indicate
that they are keywords.

Django always passed "app_configs" as a list, but checks can accept and
use a more general more Sequence.

The Django API also requires that registered checks take "**kwargs".

This results in the canonical parameters of:
"app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any"
This commit is contained in:
Brian Helba
2020-10-28 19:21:32 -04:00
committed by GitHub
parent 695cdb16ca
commit 6dc2c32382
13 changed files with 56 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any, List, Union, Iterable, Optional
from typing import Any, List, Union, Optional, Sequence
from django.contrib.admin.options import BaseModelAdmin
from django.core.checks.messages import CheckMessage, Error
@@ -7,7 +7,7 @@ from django.apps.config import AppConfig
_CheckError = Union[str, Error]
def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[_CheckError]: ...
def check_admin_app(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[_CheckError]: ...
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
class BaseModelAdminChecks: