Skip to content

Add missing descriptor methods in dataclasses and functools #7203

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

Merged
merged 8 commits into from
Feb 15, 2022
Merged
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: 2 additions & 0 deletions stdlib/dataclasses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class Field(Generic[_T]):
compare: bool,
metadata: Mapping[Any, Any],
) -> None: ...

def __set_name__(self, owner: Type[Any], name: str) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

Expand Down
8 changes: 6 additions & 2 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ class partialmethod(Generic[_T]):
def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ...
@overload
def __init__(self, __func: _Descriptor, *args: Any, **keywords: Any) -> None: ...
def __get__(self, obj: Any, cls: type[Any]) -> Callable[..., _T]: ...
if sys.version_info >= (3, 8):
def __get__(self, obj: Any, cls: type[Any] | None = ...) -> Callable[..., _T]: ...
else:
def __get__(self, obj: Any, cls: type[Any] | None) -> Callable[..., _T]: ...

@property
def __isabstractmethod__(self) -> bool: ...
if sys.version_info >= (3, 9):
Expand Down Expand Up @@ -105,7 +109,7 @@ if sys.version_info >= (3, 8):
def register(self, cls: Callable[..., _T], method: None = ...) -> Callable[..., _T]: ...
@overload
def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _S, cls: type[_S] | None = ...) -> Callable[..., _T]: ...

class cached_property(Generic[_T]):
func: Callable[[Any], _T]
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ dataclasses.KW_ONLY
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
functools.partialmethod.__get__
functools.singledispatchmethod.__call__
gettext.install
gettext.translation
hashlib.sha3_\d+ # Can be a class or a built-in function
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ dummy_threading.local.__new__
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
functools.partialmethod.__get__
functools.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable
gettext.install # codeset default value is ['unspecified'] so can't be specified
gettext.translation # codeset default value is ['unspecified'] so can't be specified
hmac.new # Stub is a white lie; see comments in the stub
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ dataclasses.field
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
functools.partialmethod.__get__
functools.singledispatchmethod.__call__
gettext.install
gettext.translation
hashlib.sha3_\d+
Expand Down