GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `functools.partial.__get__` for Python 3.14 by apoorvdarshan · Pull Request #15977 · python/typeshed

Conversation

@apoorvdarshan

@apoorvdarshan apoorvdarshan commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@apoorvdarshan
Add functools.partial.__get__ for Python 3.14
cb1729a
partial became a descriptor in 3.14 (python/cpython#121027).
@github-actions

This comment has been minimized.

Sign in to view
@srittau

srittau commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

There are failing CI checks. Please have a look at them before we can consider this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apoorvdarshan
[boltons] Make __get__ overrides compatible with functools.partial base
5b0c6f4
@apoorvdarshan

apoorvdarshan commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @srittau. Fixed the CI failure: the new functools.partial.__get__ base signature (optional owner, returns Callable[..., _T]) made boltons' InstancePartial/CachedInstancePartial __get__ overrides [override]-incompatible, since they declared obj_type as required and untyped. I updated both overrides to match the base (positional-only params, optional obj_type: type[Any] | None = None, return Callable[..., Incomplete]). mypy_test.py stubs/boltons now passes on both 3.14 and 3.15, and the stdlib change is unchanged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

This comment has been minimized.

Sign in to view
@apoorvdarshan
Fix boltons __get__ stubtest: match runtime signature + ignore[override]
2f0fc65
@apoorvdarshan

apoorvdarshan commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@srittau The previous commit resolved the mypy [override] error but broke stubtest: boltons's runtime __get__(self, obj, obj_type) requires obj_type (no default, positional-or-keyword), which no longer matched the stub after I added a default and /.

I've reverted both InstancePartial.__get__ and CachedInstancePartial.__get__ back to a signature matching the runtime (def __get__(self, obj, obj_type): ...) and added # type: ignore[override] for the LSP incompatibility that the new functools.partial.__get__ base method introduces (the base's owner is optional, but boltons requires obj_type). Also dropped the now-unused Any/Callable imports.

Verified locally: mypy_test.py stubs/boltons passes on both 3.14 and 3.15, and stubtest_third_party.py boltons now reports success.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

This comment has been minimized.

Sign in to view
@srittau srittau mentioned this pull request Jul 10, 2026
[types] Make MethodType generic #15993
Merged
JelleZijlstra
JelleZijlstra reviewed Sep 6, 2026
View reviewed changes
Comment thread stdlib/functools.pyi Outdated
def __new__(cls, func: Callable[..., _T], /, *args: Any, **kwargs: Any) -> Self: ...
def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ...
if sys.version_info >= (3, 14):
def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> Callable[..., _T]: ...

@JelleZijlstra JelleZijlstra Sep 6, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a separate overload for instance: None that returns Self to support access on the class.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JelleZijlstra added 3 commits September 5, 2026 21:56
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into codex/pr-15977-fixes
b2c04cb
@JelleZijlstra
Preserve partial objects on class descriptor access
ab103ca
@JelleZijlstra
Merge remote-tracking branch 'upstream/main' into codex/pr-15977-fixes
529e5f2
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JelleZijlstra
JelleZijlstra merged commit 733fe4a into python:main Sep 6, 2026
91 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

functools.partial should be a descriptor in 3.14

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@apoorvdarshan @srittau @JelleZijlstra
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.