Skip to content

Add functools.partial.__get__ for Python 3.14#15977

Open
apoorvdarshan wants to merge 1 commit into
python:mainfrom
apoorvdarshan:partial-descriptor-314
Open

Add functools.partial.__get__ for Python 3.14#15977
apoorvdarshan wants to merge 1 commit into
python:mainfrom
apoorvdarshan:partial-descriptor-314

Conversation

@apoorvdarshan

Copy link
Copy Markdown

Fixes #15974.

Python 3.14 made functools.partial a descriptor (python/cpython#121027), adding a __get__ method, but the stub was missing it.

This adds __get__ to partial, gated on sys.version_info >= (3, 14), mirroring the existing partialmethod.__get__ in the same file (-> Callable[..., _T]).

The runtime signature on 3.14 is (self, instance, owner=None, /) (positional-only), which the stub matches. When accessed on an instance the descriptor returns a bound method; on the class it returns the partial itself — both are Callable[..., _T].

python tests/stubtest_stdlib.py functools passes on 3.14 with this change (no new stubtest errors), and tests/mypy_test.py stdlib/functools.pyi succeeds.


Disclosure: this change was prepared with the assistance of an AI tool (Claude Code). I verified the behavior against CPython 3.14, ran stubtest and the mypy test locally, and take responsibility for the contribution and will respond to review feedback personally.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

functools.partial should be a descriptor in 3.14

1 participant