Skip to content

Commit

Permalink
Annotate Field.default_error_messages as a ClassVar (#464)
Browse files Browse the repository at this point in the history
This clarifies that this field is set on the class itself, not on instances.
  • Loading branch information
brianhelba authored Oct 4, 2023
1 parent b2e3b52 commit 9bce985
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit 9bce985

Please sign in to comment.