diff --git a/django-stubs/contrib/auth/forms.pyi b/django-stubs/contrib/auth/forms.pyi index c9bc0abea..3b673b3e8 100644 --- a/django-stubs/contrib/auth/forms.pyi +++ b/django-stubs/contrib/auth/forms.pyi @@ -6,7 +6,7 @@ from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.core.exceptions import ValidationError from django.db import models -from django.db.models.fields import _ErrorMessagesT +from django.db.models.fields import _ErrorMessagesDict from django.forms.fields import _ClassLevelWidgetT from django.forms.widgets import Widget from django.http.request import HttpRequest @@ -28,7 +28,7 @@ class UsernameField(forms.CharField): def widget_attrs(self, widget: Widget) -> dict[str, Any]: ... class BaseUserCreationForm(forms.ModelForm[_User]): - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict password1: forms.Field password2: forms.Field def __init__(self, *args: Any, **kwargs: Any) -> None: ... @@ -45,7 +45,7 @@ class UserChangeForm(forms.ModelForm[_User]): class AuthenticationForm(forms.Form): username: forms.Field password: forms.Field - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict request: HttpRequest | None user_cache: Any username_field: models.Field @@ -81,7 +81,7 @@ class PasswordResetForm(forms.Form): ) -> None: ... class SetPasswordForm(forms.Form): - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict new_password1: forms.Field new_password2: forms.Field user: AbstractBaseUser @@ -90,12 +90,12 @@ class SetPasswordForm(forms.Form): def save(self, commit: bool = ...) -> AbstractBaseUser: ... class PasswordChangeForm(SetPasswordForm): - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict old_password: forms.Field def clean_old_password(self) -> str: ... class AdminPasswordChangeForm(forms.Form): - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict required_css_class: str password1: forms.Field password2: forms.Field diff --git a/django-stubs/contrib/gis/db/models/fields.pyi b/django-stubs/contrib/gis/db/models/fields.pyi index 018c4d27e..2ab8dea13 100644 --- a/django-stubs/contrib/gis/db/models/fields.pyi +++ b/django-stubs/contrib/gis/db/models/fields.pyi @@ -14,7 +14,7 @@ from django.contrib.gis.geos import ( ) from django.core.validators import _ValidatorCallable from django.db.models.expressions import Combinable -from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices +from django.db.models.fields import Field, _ErrorMessagesMapping, _FieldChoices from django.utils.functional import _StrOrPromise # __set__ value type @@ -62,7 +62,7 @@ class BaseSpatialField(Field[_ST, _GT]): db_column: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[_ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... def deconstruct(self) -> Any: ... def db_type(self, connection: Any) -> Any: ... @@ -107,7 +107,7 @@ class GeometryField(BaseSpatialField[_ST, _GT]): db_column: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[_ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... def deconstruct(self) -> Any: ... def formfield(self, **kwargs: Any) -> Any: ... # type: ignore[override] diff --git a/django-stubs/contrib/gis/forms/fields.pyi b/django-stubs/contrib/gis/forms/fields.pyi index a2a408c6b..ac9c7f011 100644 --- a/django-stubs/contrib/gis/forms/fields.pyi +++ b/django-stubs/contrib/gis/forms/fields.pyi @@ -5,7 +5,6 @@ from django import forms class GeometryField(forms.Field): widget: Any geom_type: str - default_error_messages: Any srid: Any def __init__(self, *, srid: Any | None = ..., geom_type: Any | None = ..., **kwargs: Any) -> None: ... def to_python(self, value: Any) -> Any: ... diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 0eabe5105..a0130cfc2 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -4,7 +4,7 @@ from typing import Any, TypeVar from django.core.validators import _ValidatorCallable from django.db.models import Field, Transform from django.db.models.expressions import Combinable -from django.db.models.fields import _ErrorMessagesT, _FieldChoices +from django.db.models.fields import _ErrorMessagesDict, _ErrorMessagesMapping, _FieldChoices from django.db.models.fields.mixins import CheckFieldDefaultMixin from django.utils.functional import _StrOrPromise @@ -18,7 +18,7 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): _pyi_private_get_type: list[Any] empty_strings_allowed: bool - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: Field size: int | None default_validators: Sequence[_ValidatorCallable] @@ -48,7 +48,7 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]): db_column: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[_ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @property def description(self) -> str: ... # type: ignore diff --git a/django-stubs/contrib/postgres/forms/array.pyi b/django-stubs/contrib/postgres/forms/array.pyi index 304f6ae4a..7d4cbb37e 100644 --- a/django-stubs/contrib/postgres/forms/array.pyi +++ b/django-stubs/contrib/postgres/forms/array.pyi @@ -2,7 +2,7 @@ from collections.abc import Sequence from typing import Any from django import forms -from django.db.models.fields import _ErrorMessagesT +from django.db.models.fields import _ErrorMessagesDict from django.forms.fields import _ClassLevelWidgetT from django.forms.utils import _DataT, _FilesT from django.forms.widgets import _OptAttrs @@ -10,7 +10,7 @@ from django.forms.widgets import _OptAttrs from ..utils import prefix_validation_error as prefix_validation_error class SimpleArrayField(forms.CharField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: forms.Field delimiter: str min_length: int | None @@ -46,7 +46,7 @@ class SplitArrayWidget(forms.Widget): def needs_multipart_form(self) -> bool: ... # type: ignore class SplitArrayField(forms.Field): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: forms.Field size: int remove_trailing_nulls: bool diff --git a/django-stubs/contrib/postgres/forms/hstore.pyi b/django-stubs/contrib/postgres/forms/hstore.pyi index 4fe7fe0b9..aa90cfecf 100644 --- a/django-stubs/contrib/postgres/forms/hstore.pyi +++ b/django-stubs/contrib/postgres/forms/hstore.pyi @@ -1,12 +1,12 @@ from typing import Any from django import forms -from django.db.models.fields import _ErrorMessagesT +from django.db.models.fields import _ErrorMessagesDict from django.forms.fields import _ClassLevelWidgetT class HStoreField(forms.CharField): widget: _ClassLevelWidgetT - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict def prepare_value(self, value: Any) -> Any: ... def to_python(self, value: Any) -> dict[str, str | None]: ... # type: ignore def has_changed(self, initial: Any, data: Any) -> bool: ... diff --git a/django-stubs/contrib/postgres/forms/ranges.pyi b/django-stubs/contrib/postgres/forms/ranges.pyi index 87492e05e..4ae1df056 100644 --- a/django-stubs/contrib/postgres/forms/ranges.pyi +++ b/django-stubs/contrib/postgres/forms/ranges.pyi @@ -1,7 +1,7 @@ from typing import Any from django import forms -from django.db.models.fields import _ErrorMessagesT +from django.db.models.fields import _ErrorMessagesDict from django.forms.widgets import MultiWidget, _OptAttrs from psycopg2.extras import Range @@ -13,7 +13,7 @@ class HiddenRangeWidget(RangeWidget): def __init__(self, attrs: _OptAttrs | None = ...) -> None: ... class BaseRangeField(forms.MultiValueField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: type[forms.Field] range_type: type[Range] hidden_widget: type[forms.Widget] @@ -22,21 +22,21 @@ class BaseRangeField(forms.MultiValueField): def compress(self, values: tuple[Any | None, Any | None]) -> Range | None: ... class IntegerRangeField(BaseRangeField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: type[forms.Field] range_type: type[Range] class DecimalRangeField(BaseRangeField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: type[forms.Field] range_type: type[Range] class DateTimeRangeField(BaseRangeField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: type[forms.Field] range_type: type[Range] class DateRangeField(BaseRangeField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict base_field: type[forms.Field] range_type: type[Range] diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 5bc6c68b4..877ee412a 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -1,6 +1,6 @@ import decimal import uuid -from collections.abc import Callable, Iterable, Sequence +from collections.abc import Callable, Iterable, Mapping, Sequence from datetime import date, time, timedelta from datetime import datetime as real_datetime from typing import Any, ClassVar, Generic, Literal, Protocol, TypeVar, overload @@ -45,7 +45,8 @@ class _FieldDescriptor(Protocol[_F]): def field(self) -> _F: ... _AllLimitChoicesTo: TypeAlias = _LimitChoicesTo | _ChoicesCallable # noqa: Y047 -_ErrorMessagesT: TypeAlias = dict[str, Any] +_ErrorMessagesMapping: TypeAlias = Mapping[str, _StrOrPromise] +_ErrorMessagesDict: TypeAlias = dict[str, _StrOrPromise] # __set__ value type _ST = TypeVar("_ST", contravariant=True) @@ -143,12 +144,12 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): column: str concrete: bool default: Any - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict empty_values: Sequence[Any] creation_counter: int auto_creation_counter: int default_validators: Sequence[validators._ValidatorCallable] - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict hidden: bool system_check_removed_details: Any | None system_check_deprecated_details: Any | None @@ -177,7 +178,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): db_tablespace: str | None = ..., auto_created: bool = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... def __set__(self, instance: Any, value: _ST) -> None: ... # class access @@ -282,7 +283,7 @@ class DecimalField(Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class CharField(Field[_ST, _GT]): @@ -313,7 +314,7 @@ class CharField(Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., *, db_collation: str | None = ..., ) -> None: ... @@ -342,7 +343,7 @@ class SlugField(CharField[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., *, max_length: int | None = ..., db_index: bool = ..., @@ -377,7 +378,7 @@ class URLField(CharField[_ST, _GT]): db_tablespace: str | None = ..., auto_created: bool = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class TextField(Field[_ST, _GT]): @@ -408,7 +409,7 @@ class TextField(Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., *, db_collation: str | None = ..., ) -> None: ... @@ -431,7 +432,7 @@ class GenericIPAddressField(Field[_ST, _GT]): _pyi_private_set_type: str | int | Callable[..., Any] | Combinable _pyi_private_get_type: str - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict unpack_ipv4: bool protocol: str def __init__( @@ -455,7 +456,7 @@ class GenericIPAddressField(Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class DateTimeCheckMixin: ... @@ -489,7 +490,7 @@ class DateField(DateTimeCheckMixin, Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class TimeField(DateTimeCheckMixin, Field[_ST, _GT]): @@ -519,7 +520,7 @@ class TimeField(DateTimeCheckMixin, Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class DateTimeField(DateField[_ST, _GT]): @@ -556,7 +557,7 @@ class UUIDField(Field[_ST, _GT]): db_tablespace: str | None = ..., auto_created: bool = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class FilePathField(Field[_ST, _GT]): @@ -591,7 +592,7 @@ class FilePathField(Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class BinaryField(Field[_ST, _GT]): diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index a0e7a7d56..bcd2cca9d 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -6,7 +6,7 @@ from django.core.files.base import File from django.core.files.images import ImageFile from django.core.files.storage import Storage from django.db.models.base import Model -from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices +from django.db.models.fields import Field, _ErrorMessagesMapping, _FieldChoices from django.db.models.query_utils import DeferredAttribute from django.utils._os import _PathCompatible from django.utils.functional import _StrOrPromise @@ -68,7 +68,7 @@ class FileField(Field): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... # class access @overload diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index b36361d12..bccf8a8ab 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -5,7 +5,7 @@ from uuid import UUID from django.core import validators # due to weird mypy.stubtest error from django.db.models.base import Model from django.db.models.expressions import Combinable -from django.db.models.fields import Field, _AllLimitChoicesTo, _ErrorMessagesT, _FieldChoices, _LimitChoicesTo +from django.db.models.fields import Field, _AllLimitChoicesTo, _ErrorMessagesMapping, _FieldChoices, _LimitChoicesTo from django.db.models.fields.mixins import FieldCacheMixin from django.db.models.fields.related_descriptors import ForwardManyToOneDescriptor as ForwardManyToOneDescriptor from django.db.models.fields.related_descriptors import ( # noqa: F401 @@ -92,7 +92,7 @@ class ForeignObject(RelatedField[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... # class access @overload @@ -151,7 +151,7 @@ class ForeignKey(ForeignObject[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... class OneToOneField(ForeignKey[_ST, _GT]): @@ -192,7 +192,7 @@ class OneToOneField(ForeignKey[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... # class access @overload @@ -253,7 +253,7 @@ class ManyToManyField(RelatedField[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., validators: Iterable[validators._ValidatorCallable] = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... # class access @overload diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index 64b9faf39..86f340310 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -7,7 +7,14 @@ from uuid import UUID from django.core.files import File from django.core.validators import _ValidatorCallable -from django.db.models.fields import _Choice, _ChoiceNamedGroup, _ChoicesCallable, _ErrorMessagesT, _FieldChoices +from django.db.models.fields import ( + _Choice, + _ChoiceNamedGroup, + _ChoicesCallable, + _ErrorMessagesDict, + _ErrorMessagesMapping, + _FieldChoices, +) from django.forms.boundfield import BoundField from django.forms.forms import BaseForm from django.forms.widgets import Widget @@ -31,14 +38,14 @@ class Field: widget: _ClassLevelWidgetT hidden_widget: type[Widget] default_validators: list[_ValidatorCallable] - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict empty_values: Sequence[Any] show_hidden_initial: bool help_text: _StrOrPromise disabled: bool label_suffix: str | None localize: bool - error_messages: _ErrorMessagesT + error_messages: _ErrorMessagesDict validators: list[_ValidatorCallable] def __init__( self, @@ -48,7 +55,7 @@ class Field: label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -83,7 +90,7 @@ class CharField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -109,7 +116,7 @@ class IntegerField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -131,7 +138,7 @@ class FloatField(IntegerField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -158,7 +165,7 @@ class DecimalField(IntegerField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -180,7 +187,7 @@ class BaseTemporalField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -224,7 +231,7 @@ class RegexField(CharField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -245,7 +252,7 @@ class EmailField(CharField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -265,7 +272,7 @@ class FileField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -294,7 +301,7 @@ class URLField(CharField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -332,7 +339,7 @@ class ChoiceField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -362,7 +369,7 @@ class TypedChoiceField(ChoiceField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -390,7 +397,7 @@ class TypedMultipleChoiceField(MultipleChoiceField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -411,7 +418,7 @@ class ComboField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -433,7 +440,7 @@ class MultiValueField(Field): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -466,7 +473,7 @@ class FilePathField(ChoiceField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -487,7 +494,7 @@ class SplitDateTimeField(MultiValueField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -508,7 +515,7 @@ class GenericIPAddressField(CharField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -532,7 +539,7 @@ class SlugField(CharField): label: _StrOrPromise | None = ..., initial: Any | None = ..., help_text: _StrOrPromise = ..., - error_messages: _ErrorMessagesT | None = ..., + error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., validators: Sequence[_ValidatorCallable] = ..., localize: bool = ..., @@ -548,7 +555,7 @@ class InvalidJSONInput(str): ... class JSONString(str): ... class JSONField(CharField): - default_error_messages: _ErrorMessagesT + default_error_messages: _ErrorMessagesDict widget: _ClassLevelWidgetT encoder: Any decoder: Any diff --git a/django-stubs/forms/formsets.pyi b/django-stubs/forms/formsets.pyi index 1c0c02a7e..27f84390f 100644 --- a/django-stubs/forms/formsets.pyi +++ b/django-stubs/forms/formsets.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterator, Mapping, Sequence, Sized from typing import Any, Generic, TypeVar +from django.db.models.fields import _ErrorMessagesDict from django.forms.forms import BaseForm, Form from django.forms.utils import ErrorList, RenderableFormMixin, _DataT, _FilesT from django.forms.widgets import Media, Widget @@ -44,7 +45,7 @@ class BaseFormSet(Generic[_F], Sized, RenderableFormMixin): error_class: type[ErrorList] deletion_widget: type[Widget] ordering_widget: type[Widget] - default_error_messages: dict[str, str] + default_error_messages: _ErrorMessagesDict template_name_div: str template_name_p: str template_name_table: str diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index 6e109e5a0..b93303066 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -233,7 +233,6 @@ class InlineForeignKeyField(Field): required: bool show_hidden_initial: bool widget: _ClassLevelWidgetT - default_error_messages: dict[str, str] parent_instance: Model pk_field: bool to_field: str | None @@ -262,12 +261,10 @@ class ModelChoiceIterator: class ModelChoiceField(ChoiceField): disabled: bool - error_messages: dict[str, str] help_text: _StrOrPromise required: bool show_hidden_initial: bool validators: list[Any] - default_error_messages: dict[str, str] iterator: type[ModelChoiceIterator] empty_label: _StrOrPromise | None queryset: QuerySet[models.Model] | None @@ -307,7 +304,6 @@ class ModelMultipleChoiceField(ModelChoiceField): show_hidden_initial: bool widget: _ClassLevelWidgetT hidden_widget: type[Widget] - default_error_messages: dict[str, str] def __init__(self, queryset: None | Manager[Model] | QuerySet[Model], **kwargs: Any) -> None: ... def to_python(self, value: Any) -> list[Model]: ... # type: ignore[override] def clean(self, value: Any) -> QuerySet[Model]: ...