Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate Field.default_error_messages as a ClassVar #464

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from decimal import Decimal
from enum import Enum
from json import JSONDecoder, JSONEncoder
from re import Pattern
from typing import Any, Final, Generic, NoReturn, Protocol, TypeVar
from typing import Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeVar

from django.core.files.base import File
from django.db import models
Expand Down Expand Up @@ -72,7 +72,7 @@ class Field(Generic[_VT, _DT, _RP, _IN]):
allow_null: bool
default: _VT | None
default_empty_html: Any
default_error_messages: dict[str, StrOrPromise]
default_error_messages: ClassVar[dict[str, StrOrPromise]]
default_validators: list[Validator[_VT]]
error_messages: dict[str, StrOrPromise]
field_name: str | None
Expand Down
6 changes: 3 additions & 3 deletions rest_framework-stubs/serializers.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence
from typing import Any, Generic, Literal, NoReturn, TypeVar
from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar

from django.db import models
from django.db.models import Manager, Model, QuerySet
Expand Down Expand Up @@ -125,7 +125,7 @@ class Serializer(
metaclass=SerializerMetaclass,
):
_declared_fields: dict[str, Field]
default_error_messages: dict[str, StrOrPromise]
default_error_messages: ClassVar[dict[str, StrOrPromise]]
def get_initial(self) -> Any: ...
@cached_property
def fields(self) -> BindingDict: ...
Expand All @@ -148,7 +148,7 @@ class ListSerializer(
):
child: Field | BaseSerializer | None
many: bool
default_error_messages: dict[str, StrOrPromise]
default_error_messages: ClassVar[dict[str, StrOrPromise]]
allow_empty: bool | None
def __init__(
self,
Expand Down