Description
from typing import Any, Generic, TypeVar, overload
from typing_extensions import deprecated
T = TypeVar("T")
class Works:
@overload
def __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: ...
class Fails(Generic[T]):
@overload
def __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: ...
class Class:
works = Works()
fails = Fails[int]()
Class().works
Class().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 function repro.Works.__get__ is deprecated: Accessing this attribute on the instance is deprecated [deprecated]
(on mypy 1.14)