Skip to content
Open
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
3 changes: 0 additions & 3 deletions stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ types.UnionType.__mro_entries__
types.UnionType.__name__
types.UnionType.__qualname__

# Assigning `__new__` causes `func` not to get recognized.
functools.partialmethod.__new__

# Decorator approximated by classmethod
concurrent.interpreters._crossinterp.classonly.*
# Method using this decorator
Expand Down
3 changes: 0 additions & 3 deletions stdlib/@tests/stubtest_allowlists/py315.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ concurrent.interpreters._crossinterp.UNBOUND_REMOVE
# Condition functions are exported in __init__
threading.Condition.locked

# Assigning `__new__` causes `func` not to get recognized.
functools.partialmethod.__new__

# These protocols use ABC hackery at runtime.
(io|typing_extensions)\.Reader\.__class_getitem__
(io|typing_extensions)\.Reader\.read
Expand Down
20 changes: 18 additions & 2 deletions stdlib/@tests/test_cases/check_functools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from functools import cache, cached_property, lru_cache, singledispatchmethod, update_wrapper, wraps
from typing import Callable, ParamSpec, TypeVar
from collections.abc import Callable
from functools import cache, cached_property, lru_cache, partialmethod, singledispatchmethod, update_wrapper, wraps
from typing import ParamSpec, TypeVar
from typing_extensions import assert_type

P = ParamSpec("P")
Expand Down Expand Up @@ -225,3 +226,18 @@ def format_float(self: Formatter, value: float) -> str:
assert_type(formatter.format.__name__, str)
assert_type(formatter.format.__qualname__, str)
assert_type(formatter.format.__wrapped__, Callable[..., str])


def _pm_func(arg: object, /, *, options: dict[str, str]) -> str:
return "dummy"


pm = partialmethod(_pm_func, options={})
assert_type(pm, partialmethod[str])


class _Bar:
my_method = partialmethod(_pm_func, options={})


assert_type(_Bar().my_method(), str)
8 changes: 1 addition & 7 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,9 @@ class partialmethod(Generic[_T]):
args: tuple[Any, ...]
keywords: dict[str, Any]
if sys.version_info >= (3, 14):
@overload
def __new__(self, func: Callable[..., _T], /, *args: Any, **keywords: Any) -> Self: ...
@overload
def __new__(self, func: _Descriptor, /, *args: Any, **keywords: Any) -> Self: ...
def __new__(cls, func: Callable[..., _T], /, *args: Any, **keywords: Any) -> Self: ...
else:
@overload
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] | None = None) -> Callable[..., _T]: ...
@property
Expand Down
Loading