mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 12:44:29 +08:00
Allow overridable checks to be CheckMessage (#497)
* Allow overridable checks to be CheckMessage The checks framework expects return types to be "List[CheckMessage]". This allows all overridable checks-returning methods to return the more general "CheckMessage", instead of the "Error" subclass. * Ignore an incorrect usage of the checks API in Django 2.2
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from typing import Any, List, Union, Iterable, Optional
|
from typing import Any, List, Union, Iterable, Optional
|
||||||
|
|
||||||
from django.contrib.admin.options import BaseModelAdmin
|
from django.contrib.admin.options import BaseModelAdmin
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage, Error
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -
|
|||||||
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
||||||
|
|
||||||
class BaseModelAdminChecks:
|
class BaseModelAdminChecks:
|
||||||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
|
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|
||||||
class ModelAdminChecks(BaseModelAdminChecks): ...
|
class ModelAdminChecks(BaseModelAdminChecks): ...
|
||||||
class InlineModelAdminChecks(BaseModelAdminChecks): ...
|
class InlineModelAdminChecks(BaseModelAdminChecks): ...
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from django.contrib.admin.sites import AdminSite
|
|||||||
from django.contrib.admin.views.main import ChangeList
|
from django.contrib.admin.views.main import ChangeList
|
||||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
|
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
|
||||||
@@ -75,7 +75,7 @@ class BaseModelAdmin:
|
|||||||
view_on_site: bool = ...
|
view_on_site: bool = ...
|
||||||
show_full_result_count: bool = ...
|
show_full_result_count: bool = ...
|
||||||
checks_class: Any = ...
|
checks_class: Any = ...
|
||||||
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
|
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def formfield_for_dbfield(
|
def formfield_for_dbfield(
|
||||||
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
|
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
|
||||||
) -> Optional[Field]: ...
|
) -> Optional[Field]: ...
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.expressions import Combinable
|
from django.db.models.expressions import Combinable
|
||||||
from django.db.models.fields.mixins import FieldCacheMixin
|
from django.db.models.fields.mixins import FieldCacheMixin
|
||||||
@@ -41,7 +41,7 @@ class GenericForeignKey(FieldCacheMixin):
|
|||||||
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
||||||
def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, Optional[ContentType]]: ...
|
def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, Optional[ContentType]]: ...
|
||||||
def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ...
|
def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ...
|
||||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def get_cache_name(self) -> str: ...
|
def get_cache_name(self) -> str: ...
|
||||||
def get_content_type(
|
def get_content_type(
|
||||||
self, obj: Optional[Model] = ..., id: Optional[int] = ..., using: Optional[str] = ...
|
self, obj: Optional[Model] = ..., id: Optional[int] = ..., using: Optional[str] = ...
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload
|
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload
|
||||||
|
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage
|
||||||
from django.core.files.storage import Storage
|
from django.core.files.storage import Storage
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
|
||||||
searched_locations: Any
|
searched_locations: Any
|
||||||
|
|
||||||
class BaseFinder:
|
class BaseFinder:
|
||||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def find(self, path: str, all: bool = ...) -> Optional[Any]: ...
|
def find(self, path: str, all: bool = ...) -> Optional[Any]: ...
|
||||||
def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
|
def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from typing import (
|
|||||||
overload,
|
overload,
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.core import checks
|
from django.core.checks import CheckMessage
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
||||||
@@ -132,7 +132,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
|||||||
) -> Sequence[Union[_Choice, _ChoiceNamedGroup]]: ...
|
) -> Sequence[Union[_Choice, _ChoiceNamedGroup]]: ...
|
||||||
def has_default(self) -> bool: ...
|
def has_default(self) -> bool: ...
|
||||||
def get_default(self) -> Any: ...
|
def get_default(self) -> Any: ...
|
||||||
def check(self, **kwargs: Any) -> List[checks.Error]: ...
|
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
@property
|
@property
|
||||||
def validators(self) -> List[_ValidatorCallable]: ...
|
def validators(self) -> List[_ValidatorCallable]: ...
|
||||||
def validate(self, value: Any, model_instance: Model) -> None: ...
|
def validate(self, value: Any, model_instance: Model) -> None: ...
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ IGNORED_ERRORS = {
|
|||||||
'error: "HttpResponse" has no attribute "streaming_content"',
|
'error: "HttpResponse" has no attribute "streaming_content"',
|
||||||
'error: "HttpResponse" has no attribute "context_data"',
|
'error: "HttpResponse" has no attribute "context_data"',
|
||||||
],
|
],
|
||||||
|
'admin_checks': [
|
||||||
|
'Argument 1 to "append" of "list" has incompatible type "str"; expected "CheckMessage"'
|
||||||
|
],
|
||||||
'admin_inlines': [
|
'admin_inlines': [
|
||||||
'error: "HttpResponse" has no attribute "rendered_content"',
|
'error: "HttpResponse" has no attribute "rendered_content"',
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user