From 35bd24158a014b51fde66f024234928e13d5a12a Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Thu, 19 Oct 2023 10:23:33 -0400 Subject: [PATCH] Fix Field.formfield(), GeometryField.formfield() methods (#1778) This partially reverts and fixes bugs introduced in 9010b5f8569255c55bc2253602a90eba2e57f46c. --- django-stubs/contrib/gis/db/models/fields.pyi | 9 +++++++-- django-stubs/db/models/fields/__init__.pyi | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/django-stubs/contrib/gis/db/models/fields.pyi b/django-stubs/contrib/gis/db/models/fields.pyi index 9de810933..30e061930 100644 --- a/django-stubs/contrib/gis/db/models/fields.pyi +++ b/django-stubs/contrib/gis/db/models/fields.pyi @@ -109,8 +109,13 @@ class GeometryField(BaseSpatialField[_ST, _GT]): error_messages: _ErrorMessagesMapping | None = ..., ) -> None: ... def formfield( # type: ignore[override] - self, *, form_class: type[GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any - ) -> GeometryField: ... + self, + *, + form_class: type[forms.GeometryField] | None = ..., + geom_type: str = ..., + srid: Any = ..., + **kwargs: Any, + ) -> forms.GeometryField: ... def select_format(self, compiler: Any, sql: Any, params: Any) -> Any: ... class PointField(GeometryField[_ST, _GT]): diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 471245bf8..279131eca 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -205,10 +205,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): # TODO: plugin support def formfield( self, - form_class: type[Field] | None = ..., + form_class: type[forms.Field] | None = ..., choices_form_class: type[forms.ChoiceField] | None = ..., **kwargs: Any, - ) -> Field: ... + ) -> forms.Field: ... def save_form_data(self, instance: Model, data: Any) -> None: ... def contribute_to_class(self, cls: type[Model], name: str, private_only: bool = ...) -> None: ... def to_python(self, value: Any) -> Any: ...