diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 279131eca..0853fb9cd 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -187,10 +187,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): def __get__(self, instance: None, owner: Any) -> _FieldDescriptor[Self]: ... # Model instance access @overload - def __get__(self, instance: Model, owner: Any) -> _GT: ... - # non-Model instances - @overload - def __get__(self, instance: Any, owner: Any) -> Self: ... + def __get__(self, instance: object, owner: Any) -> _GT: ... def deconstruct(self) -> tuple[str, str, Sequence[Any], dict[str, Any]]: ... def set_attributes_from_name(self, name: str) -> None: ... def db_type_parameters(self, connection: BaseDatabaseWrapper) -> DictWrapper: ... diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index bcd2cca9d..bd955b0d7 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -10,7 +10,6 @@ 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 -from typing_extensions import Self class FieldFile(File): instance: Model @@ -75,10 +74,7 @@ class FileField(Field): def __get__(self, instance: None, owner: Any) -> FileDescriptor: ... # Model instance access @overload - def __get__(self, instance: Model, owner: Any) -> Any: ... - # non-Model instances - @overload - def __get__(self, instance: Any, owner: Any) -> Self: ... + def __get__(self, instance: object, owner: Any) -> Any: ... def generate_filename(self, instance: Model | None, filename: _PathCompatible) -> str: ... class ImageFileDescriptor(FileDescriptor): @@ -103,8 +99,5 @@ class ImageField(FileField): def __get__(self, instance: None, owner: Any) -> ImageFileDescriptor: ... # Model instance access @overload - def __get__(self, instance: Model, owner: Any) -> Any: ... - # non-Model instances - @overload - def __get__(self, instance: Any, owner: Any) -> Self: ... + def __get__(self, instance: object, owner: Any) -> Any: ... def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index d5c36ccc9..67445abb1 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -98,10 +98,7 @@ class ForeignObject(RelatedField[_ST, _GT]): def __get__(self, instance: None, owner: Any) -> ForwardManyToOneDescriptor[Self]: ... # Model instance access @overload - def __get__(self, instance: Model, owner: Any) -> _GT: ... - # non-Model instances - @overload - def __get__(self, instance: Any, owner: Any) -> Self: ... + def __get__(self, instance: object, owner: Any) -> _GT: ... def resolve_related_fields(self) -> list[tuple[Field, Field]]: ... @property def related_fields(self) -> list[tuple[Field, Field]]: ... @@ -198,10 +195,7 @@ class OneToOneField(ForeignKey[_ST, _GT]): def __get__(self, instance: None, owner: Any) -> ForwardOneToOneDescriptor[Self]: ... # Model instance access @overload - def __get__(self, instance: Model, owner: Any) -> _GT: ... - # non-Model instances - @overload - def __get__(self, instance: Any, owner: Any) -> Self: ... + def __get__(self, instance: object, owner: Any) -> _GT: ... _To = TypeVar("_To", bound=Model) @@ -256,10 +250,7 @@ class ManyToManyField(RelatedField[Any, Any], Generic[_To, _M]): def __get__(self, instance: None, owner: Any) -> ManyToManyDescriptor[_M]: ... # Model instance access @overload - def __get__(self, instance: Model, owner: Any) -> ManyRelatedManager[_To]: ... - # non-Model instances - @overload - def __get__(self, instance: Any, owner: Any) -> Self: ... + def __get__(self, instance: object, owner: Any) -> ManyRelatedManager[_To]: ... def get_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... def get_reverse_path_info(self, filtered_relation: FilteredRelation | None = ...) -> list[PathInfo]: ... def contribute_to_related_class(self, cls: type[Model], related: RelatedField) -> None: ...