diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 7896e910c81f..940b8f3d4c76 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -15,7 +15,7 @@ class ABCMeta(type): def abstractmethod(funcobj: _FuncT) -> _FuncT: ... -class abstractproperty(property): ... +class abstractproperty(property[Any, Any]): ... # These two are deprecated and not supported by mypy def abstractstaticmethod(callable: _FuncT) -> _FuncT: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 095921f6bb00..7844edd65de7 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -920,22 +920,28 @@ class range(Sequence[int]): def __repr__(self) -> str: ... def __reversed__(self) -> Iterator[int]: ... -class property(object): - fget: Callable[[Any], Any] | None - fset: Callable[[Any, Any], None] | None - fdel: Callable[[Any], None] | None +_F = TypeVar("_F", contravariant=True) +_G = TypeVar("_G", covariant=True) + +class property(Generic[_F, _G]): + fget: Callable[[_F], _G] | None + fset: Callable[[_F, _G], None] | None + fdel: Callable[[_G], None] | None def __init__( self, - fget: Callable[[Any], Any] | None = ..., - fset: Callable[[Any, Any], None] | None = ..., - fdel: Callable[[Any], None] | None = ..., + fget: Callable[[_F], _G] | None = ..., + fset: Callable[[_F, _G], None] | None = ..., + fdel: Callable[[_G], None] | None = ..., doc: str | None = ..., ) -> None: ... - def getter(self, fget: Callable[[Any], Any]) -> property: ... - def setter(self, fset: Callable[[Any, Any], None]) -> property: ... - def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: type | None = ...) -> Any: ... - def __set__(self, obj: Any, value: Any) -> None: ... + def getter(self: _T, fget: Callable[[_F], _G]) -> _T: ... + def setter(self: _T, fset: Callable[[_F, _G], None]) -> _T: ... + def deleter(self: _T, fdel: Callable[[_G], None]) -> _T: ... + @overload + def __get__(self, obj: _F, type: type | None = ...) -> _G: ... + @overload + def __get__(self: _T, obj: None, type: type | None = ...) -> _T: ... + def __set__(self, obj: _F, value: Any) -> None: ... def __delete__(self, obj: Any) -> None: ... class _NotImplementedType(Any): # type: ignore diff --git a/stubs/Werkzeug/werkzeug/utils.pyi b/stubs/Werkzeug/werkzeug/utils.pyi index 5b4f507dea98..96437226db06 100644 --- a/stubs/Werkzeug/werkzeug/utils.pyi +++ b/stubs/Werkzeug/werkzeug/utils.pyi @@ -3,7 +3,7 @@ from typing import Any, Text, Type, TypeVar, overload from werkzeug._internal import _DictAccessorProperty from werkzeug.wrappers import Response -class cached_property(property): +class cached_property(property[Any, Any]): __name__: Any __module__: Any __doc__: Any