Skip to content

Commit 733fe4a

Browse files
Add functools.partial.__get__ for Python 3.14 (#15977)
partial became a descriptor in 3.14 (python/cpython#121027). Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent db0b19e commit 733fe4a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

stdlib/functools.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ class partial(Generic[_T]):
177177
def keywords(self) -> dict[str, Any]: ...
178178
def __new__(cls, func: Callable[..., _T], /, *args: Any, **kwargs: Any) -> Self: ...
179179
def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ...
180+
if sys.version_info >= (3, 14):
181+
@overload
182+
def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ...
183+
@overload
184+
def __get__(self, instance: object, owner: type[Any] | None = None, /) -> Callable[..., _T]: ...
185+
180186
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
181187

182188
# With protocols, this could change into a generic protocol that defines __get__ and returns _T

stubs/boltons/boltons/funcutils.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def copy_function(orig, copy_dict: bool = True): ...
3030
def partial_ordering(cls): ...
3131

3232
class InstancePartial(functools.partial[Incomplete]):
33-
def __get__(self, obj, obj_type): ...
33+
def __get__(self, obj, obj_type): ... # type: ignore[override]
3434

3535
class CachedInstancePartial(functools.partial[Incomplete]):
3636
__name__: Incomplete
3737
def __set_name__(self, obj_type, name) -> None: ...
3838
__doc__: Incomplete
3939
__module__: Incomplete
40-
def __get__(self, obj, obj_type): ...
40+
def __get__(self, obj, obj_type): ... # type: ignore[override]
4141

4242
partial = CachedInstancePartial
4343

0 commit comments

Comments
 (0)