mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-15 16:27:09 +08:00
Ensure that all registered checks return a list of CheckMessage (#508)
* Ensure that all registered checks return a list of CheckMessage This changes missing and Any return types on registered checks to always return "List[CheckMessage]". In many cases, check functions were already annotated to return in a more specific type than CheckMessage (e.g. Error). In these cases, it's assumed that the existing annotation is correct, and the more specific type is kept. * Update model_checks.pyi Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
@@ -1,14 +1,12 @@
|
|||||||
from typing import Any, List, Union, Optional, Sequence
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
from django.contrib.admin.options import BaseModelAdmin
|
from django.contrib.admin.options import BaseModelAdmin
|
||||||
from django.core.checks.messages import CheckMessage, Error
|
from django.core.checks.messages import CheckMessage, Error
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
_CheckError = Union[str, Error]
|
def check_admin_app(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
|
||||||
|
def check_dependencies(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
|
||||||
def check_admin_app(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[_CheckError]: ...
|
|
||||||
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
|
||||||
|
|
||||||
class BaseModelAdminChecks:
|
class BaseModelAdminChecks:
|
||||||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ...
|
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ from django.core.checks.messages import CheckMessage
|
|||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
def check_user_model(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
def check_user_model(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def check_models_permissions(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
def check_models_permissions(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
from typing import Any, List, Optional, Sequence
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
|
from django.core.checks.messages import CheckMessage
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
def check_generic_foreign_keys(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
def check_generic_foreign_keys(
|
||||||
def check_model_name_lengths(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
|
||||||
|
) -> List[CheckMessage]: ...
|
||||||
|
def check_model_name_lengths(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from typing import Any, Optional, Sequence
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
|
from django.core.checks.messages import CheckMessage
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
E001: Any
|
E001: Any
|
||||||
|
|
||||||
def check_async_unsafe(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any): ...
|
def check_async_unsafe(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
from typing import Any, List, Optional, Sequence
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
from django.core.checks.messages import Warning
|
from django.core.checks.messages import CheckMessage, Warning
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
def check_all_models(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
|
def check_all_models(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def check_lazy_references(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
def check_lazy_references(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user