Skip to content

Generic descriptors with a deprecated __get__ overload #18323

Description

@Viicos
fromtypingimportAny, Generic, TypeVar, overloadfromtyping_extensionsimportdeprecatedT=TypeVar("T")
classWorks:
@overloaddef__get__(self, instance: None, objtype: Any) ->int: ...
@overload@deprecated("Accessing this attribute on the instance is deprecated",category=None, )def__get__(self, instance: 'Class', objtype: Any) ->int: ...
classFails(Generic[T]):
@overloaddef__get__(self, instance: None, objtype: Any) ->T: ...
@overload@deprecated("Accessing this attribute on the instance is deprecated",category=None, )def__get__(self, instance: 'Class', objtype: Any) ->T: ...
classClass:
works=Works()
fails=Fails[int]()
Class().worksClass().fails
$ mypy --enable-error-code=deprecated --disable-error-code=no-overload-impl repro.py
repro.py:86: error: overload def (self: repro.Works, instance: repro.Class, objtype: Any) -> builtins.int of functionrepro.Works.__get__ is deprecated: Accessing this attribute on the instance is deprecated [deprecated]

(on mypy 1.14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions