diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index 9a3aa9f75..b0ed107c5 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -28,7 +28,7 @@ class ArrayField(CheckPostgresInstalledMixin, CheckFieldDefaultMixin, Field[_ST, default_error_messages: ClassVar[_ErrorMessagesDict] base_field: Field size: int | None - default_validators: Sequence[_ValidatorCallable] + default_validators: list[_ValidatorCallable] from_db_value: Any def __init__( self, diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 5fc8ca280..60e64c472 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -6,8 +6,8 @@ from datetime import datetime as real_datetime from typing import Any, ClassVar, Generic, Protocol, TypeAlias, overload, type_check_only from django import forms -from django.core import validators # due to weird mypy.stubtest error from django.core.checks import CheckMessage +from django.core.validators import _ValidatorCallable from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models import Model from django.db.models.expressions import Col, Combinable, Expression, Func @@ -144,7 +144,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): empty_values: Sequence[Any] creation_counter: int auto_creation_counter: int - default_validators: Sequence[validators._ValidatorCallable] + default_validators: list[_ValidatorCallable] default_error_messages: ClassVar[_ErrorMessagesDict] hidden: bool system_check_removed_details: Any | None @@ -172,7 +172,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): db_column: str | None = None, db_tablespace: str | None = None, auto_created: bool = False, - validators: Iterable[validators._ValidatorCallable] = (), + validators: Iterable[_ValidatorCallable] = (), error_messages: _ErrorMessagesMapping | None = None, db_comment: str | None = None, db_default: type[NOT_PROVIDED] | Expression | _ST = ..., @@ -205,7 +205,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): @cached_property def error_messages(self) -> _ErrorMessagesDict: ... @cached_property - def validators(self) -> list[validators._ValidatorCallable]: ... + def validators(self) -> list[_ValidatorCallable]: ... def run_validators(self, value: Any) -> None: ... def validate(self, value: Any, model_instance: Model | None) -> None: ... def clean(self, value: Any, model_instance: Model | None) -> Any: ... @@ -325,7 +325,7 @@ class DecimalField(Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @cached_property @@ -361,7 +361,7 @@ class CharField(Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., *, db_collation: str | None = None, @@ -393,7 +393,7 @@ class SlugField(CharField[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., *, max_length: int | None = 50, @@ -434,7 +434,7 @@ class URLField(CharField[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., auto_created: bool = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @override @@ -468,7 +468,7 @@ class TextField(Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., *, db_collation: str | None = None, @@ -520,7 +520,7 @@ class GenericIPAddressField(Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @override @@ -558,7 +558,7 @@ class DateField(DateTimeCheckMixin, Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @override @@ -593,7 +593,7 @@ class TimeField(DateTimeCheckMixin, Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @override @@ -635,7 +635,7 @@ class UUIDField(Field[_ST, _GT]): db_comment: str | None = ..., db_tablespace: str | None = ..., auto_created: bool = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @override @@ -673,7 +673,7 @@ class FilePathField(Field[_ST, _GT]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... @override diff --git a/django-stubs/db/models/fields/composite.pyi b/django-stubs/db/models/fields/composite.pyi index 1a9f97dc1..31786b82b 100644 --- a/django-stubs/db/models/fields/composite.pyi +++ b/django-stubs/db/models/fields/composite.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterable, Iterator, Mapping from typing import Any, Literal -from django.core import validators # due to weird mypy.stubtest error +from django.core.validators import _ValidatorCallable from django.db.models import NOT_PROVIDED, Field from django.db.models.base import Model from django.db.models.fields.reverse_related import ForeignObjectRel @@ -48,7 +48,7 @@ class CompositePrimaryKey(Field[Any, Any]): db_column: None = None, db_tablespace: str | None = None, auto_created: bool = False, - validators: Iterable[validators._ValidatorCallable] = (), + validators: Iterable[_ValidatorCallable] = (), error_messages: Mapping[str, _StrOrPromise] | None = None, db_comment: str | None = None, db_default: type[NOT_PROVIDED] = ..., diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index 4bcc92686..59a258a58 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -2,10 +2,10 @@ import sys from collections.abc import Callable, Iterable from typing import Any, Protocol, overload, type_check_only -from django.core import validators # due to weird mypy.stubtest error from django.core.files.base import File from django.core.files.images import ImageFile from django.core.files.storage import Storage +from django.core.validators import _ValidatorCallable from django.db.models.base import Model from django.db.models.expressions import Expression from django.db.models.fields import NOT_PROVIDED, Field, _ErrorMessagesMapping @@ -90,7 +90,7 @@ class FileField(Field[Any, Any]): db_column: str | None = ..., db_comment: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... # class access diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index efba88ee2..bfedf4e63 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -3,7 +3,7 @@ from typing import Any, Generic, Literal, overload from uuid import UUID from django import forms -from django.core import validators # due to weird mypy.stubtest error +from django.core.validators import _ValidatorCallable from django.db.backends.base.base import BaseDatabaseWrapper from django.db.models.base import Model from django.db.models.expressions import Combinable, Expression @@ -73,7 +73,7 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]): db_column: str | None = ..., db_tablespace: str | None = ..., auto_created: bool = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., db_comment: str | None = ..., ) -> None: ... @@ -130,7 +130,7 @@ class ForeignObject(RelatedField[_ST, _GT]): help_text: _StrOrPromise = ..., db_column: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., db_comment: str | None = ..., ) -> None: ... @@ -216,7 +216,7 @@ class ForeignKey(ForeignObject[_ST, _GT]): help_text: _StrOrPromise = ..., db_column: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., db_comment: str | None = ..., ) -> None: ... @@ -270,7 +270,7 @@ class OneToOneField(ForeignKey[_ST, _GT]): help_text: _StrOrPromise = ..., db_column: str | None = ..., db_tablespace: str | None = ..., - validators: Iterable[validators._ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., error_messages: _ErrorMessagesMapping | None = ..., db_comment: str | None = ..., ) -> None: ... diff --git a/django-stubs/forms/fields.pyi b/django-stubs/forms/fields.pyi index b4e1723c5..e66492289 100644 --- a/django-stubs/forms/fields.pyi +++ b/django-stubs/forms/fields.pyi @@ -1,5 +1,5 @@ import datetime -from collections.abc import Callable, Collection, Iterator, Sequence +from collections.abc import Callable, Collection, Iterable, Iterator, Sequence from decimal import Decimal from re import Pattern from typing import Any, ClassVar, Protocol, TypeAlias, type_check_only @@ -52,7 +52,7 @@ class Field: help_text: _StrOrPromise = "", error_messages: _ErrorMessagesMapping | None = None, show_hidden_initial: bool = False, - validators: Sequence[_ValidatorCallable] = (), + validators: Iterable[_ValidatorCallable] = (), localize: bool = False, disabled: bool = False, label_suffix: str | None = None, @@ -89,7 +89,7 @@ class CharField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -118,7 +118,7 @@ class IntegerField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -142,7 +142,7 @@ class FloatField(IntegerField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -172,7 +172,7 @@ class DecimalField(IntegerField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -197,7 +197,7 @@ class BaseTemporalField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -255,7 +255,7 @@ class RegexField(CharField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -277,7 +277,7 @@ class EmailField(CharField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -299,7 +299,7 @@ class FileField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -335,7 +335,7 @@ class URLField(CharField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -377,7 +377,7 @@ class ChoiceField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -412,7 +412,7 @@ class TypedChoiceField(ChoiceField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -446,7 +446,7 @@ class TypedMultipleChoiceField(MultipleChoiceField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -469,7 +469,7 @@ class ComboField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -492,7 +492,7 @@ class MultiValueField(Field): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -530,7 +530,7 @@ class FilePathField(ChoiceField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -553,7 +553,7 @@ class SplitDateTimeField(MultiValueField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -575,7 +575,7 @@ class GenericIPAddressField(CharField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ..., @@ -600,7 +600,7 @@ class SlugField(CharField): help_text: _StrOrPromise = ..., error_messages: _ErrorMessagesMapping | None = ..., show_hidden_initial: bool = ..., - validators: Sequence[_ValidatorCallable] = ..., + validators: Iterable[_ValidatorCallable] = ..., localize: bool = ..., disabled: bool = ..., label_suffix: str | None = ...,