FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-84644: Fix singledispatch annotation parsing by johnslavik · Pull Request #143465 · python/cpython · GitHub

Repository navigation

gh-84644: Fix singledispatch annotation parsing - #143465

Open
johnslavik wants to merge 108 commits into
python:mainfrom
johnslavik:fix-singledispatch-annotation-parsing
Open

johnslavik wants to merge 108 commits into
python:mainfrom
johnslavik:fix-singledispatch-annotation-parsing

Conversation

johnslavik commented Jan 6, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

A very practical but more general approach than GH-140255 to fixing annotation parsing in functools.singledispatch and functools.singledispatchmethod.

Fixes issues GH-84644, GH-130827, and GH-143886.

It can be broken if one uses a user-defined alternative implementation of staticmethod or something analogous.
Will break incorrect but working registrees. I haven't investigated stripping Annotated typeforms yet.

Consulting a test which fails with this fix at https://github.com/python/cpython/pull/130309/changes#r2663516538 -- I think that the test is wrong.

Comment thread Lib/functools.py Outdated

This comment was marked as resolved.

Comment thread Lib/functools.py Outdated
Comment thread Lib/functools.py Outdated
johnslavik force-pushed the fix-singledispatch-annotation-parsing branch from 0d72cec to a5a79ad Compare July 20, 2026 23:41

johnslavik commented Jul 20, 2026 •
edited
Loading

Copy link
Copy Markdown
Member Author

@picnixz, could you please re-review? :)

(The force-push was intentional; I know this is discouraged but I want to save noise, you can still follow what happened.)

Comment thread Lib/functools.py Outdated

read-the-docs-community Bot commented Jul 20, 2026 •
edited
Loading

Copy link
Copy Markdown

johnslavik requested a review from picnixz July 21, 2026 02:13
Comment thread Doc/library/functools.rst

JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not sure it's valuable to specifically disallow return annotations if we still allow dispatching by annotations on wrong parameters.

johnslavik commented Aug 30, 2026 •
edited
Loading

Copy link
Copy Markdown
Member Author

I'm not sure it's valuable to specifically disallow return annotations if we still allow dispatching by annotations on wrong parameters.

We could deprecate cases when the chosen parameter isn't the same as in my new formula. @picnixz prefers to just document the limitation. And when the deprecation ends, we break custom descriptors that emulate static method behavior (which nowadays seems less of a risk than I originally thought, case looks extremely rare and it's a trivial fix).

encukou commented Sep 2, 2026

Copy link
Copy Markdown
Member

I'm not sure it's valuable to specifically disallow return annotations if we still allow dispatching by annotations on wrong parameters.

Yeah, it's not very valuable. But in other cases we can't really be sure something is wrong, and the check is cheap. +0; I'd merge it.

github-project-automation Bot moved this to Todo in Sprint Oct 20, 2026
github-project-automation Bot moved this from Todo to In Progress in Sprint Oct 20, 2026
johnslavik removed the needs backport to 3.13 only security fixes label Oct 20, 2026
encukou removed needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 20, 2026

encukou commented Oct 20, 2026

Copy link
Copy Markdown
Member

New deprecations should not get backported. The docs improvements will need manual backports.

encukou previously approved these changes Oct 20, 2026
encukou dismissed their stale review October 20, 2026 17:11

I was too quick :/

Comment thread Doc/library/functools.rst Outdated
rhettinger removed their request for review October 20, 2026 18:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL