Skip to content

make property generic #5987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
30 changes: 18 additions & 12 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stubs/Werkzeug/werkzeug/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down