Skip to content

Commit 96b06ad

Browse files
authored
Add missing descriptor methods in dataclasses and functools (#7203)
1 parent feb20fc commit 96b06ad

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

stdlib/dataclasses.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class Field(Generic[_T]):
111111
compare: bool,
112112
metadata: Mapping[Any, Any],
113113
) -> None: ...
114+
115+
def __set_name__(self, owner: Type[Any], name: str) -> None: ...
114116
if sys.version_info >= (3, 9):
115117
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
116118

stdlib/functools.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ class partialmethod(Generic[_T]):
6969
def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ...
7070
@overload
7171
def __init__(self, __func: _Descriptor, *args: Any, **keywords: Any) -> None: ...
72-
def __get__(self, obj: Any, cls: type[Any]) -> Callable[..., _T]: ...
72+
if sys.version_info >= (3, 8):
73+
def __get__(self, obj: Any, cls: type[Any] | None = ...) -> Callable[..., _T]: ...
74+
else:
75+
def __get__(self, obj: Any, cls: type[Any] | None) -> Callable[..., _T]: ...
76+
7377
@property
7478
def __isabstractmethod__(self) -> bool: ...
7579
if sys.version_info >= (3, 9):
@@ -107,7 +111,7 @@ if sys.version_info >= (3, 8):
107111
def register(self, cls: Callable[..., _T], method: None = ...) -> Callable[..., _T]: ...
108112
@overload
109113
def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
110-
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
114+
def __get__(self, obj: _S, cls: type[_S] | None = ...) -> Callable[..., _T]: ...
111115

112116
class cached_property(Generic[_T]):
113117
func: Callable[[Any], _T]

tests/stubtest_allowlists/py310.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ dataclasses.KW_ONLY
5050
enum.Enum._generate_next_value_
5151
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
5252
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
53-
functools.partialmethod.__get__
54-
functools.singledispatchmethod.__call__
5553
gettext.install
5654
gettext.translation
5755
hashlib.sha3_\d+ # Can be a class or a built-in function

tests/stubtest_allowlists/py38.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ dummy_threading.local.__new__
3737
enum.Enum._generate_next_value_
3838
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
3939
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
40-
functools.partialmethod.__get__
41-
functools.singledispatchmethod.__call__ # A lie to reflect that the descriptor get returns a callable
4240
gettext.install # codeset default value is ['unspecified'] so can't be specified
4341
gettext.translation # codeset default value is ['unspecified'] so can't be specified
4442
hmac.new # Stub is a white lie; see comments in the stub

tests/stubtest_allowlists/py39.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ dataclasses.field
3636
enum.Enum._generate_next_value_
3737
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
3838
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
39-
functools.partialmethod.__get__
40-
functools.singledispatchmethod.__call__
4139
gettext.install
4240
gettext.translation
4341
hashlib.sha3_\d+

0 commit comments

Comments
 (0)