Skip to content

gh-84644: Fix singledispatch annotation parsing#143465

Open
johnslavik wants to merge 102 commits intopython:mainfrom
johnslavik:fix-singledispatch-annotation-parsing
Open

gh-84644: Fix singledispatch annotation parsing#143465
johnslavik wants to merge 102 commits intopython:mainfrom
johnslavik:fix-singledispatch-annotation-parsing

Conversation

@johnslavik
Copy link
Member

@johnslavik johnslavik commented Jan 6, 2026

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.

@johnslavik

This comment was marked as resolved.

@johnslavik
Copy link
Member Author

johnslavik commented Feb 8, 2026

Hold on, I'll also think about the prospect of fixing GH-143535 separately.

This could be simplified with that other issue in mind.

@johnslavik johnslavik marked this pull request as draft February 8, 2026 22:22
@johnslavik johnslavik marked this pull request as ready for review February 8, 2026 23:36
@johnslavik
Copy link
Member Author

I'm thinking that this could be labeled a new feature to minimize risks, similar to #144615.

cc @picnixz @encukou, what are your thoughts?

@picnixz picnixz removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 1, 2026
@picnixz
Copy link
Member

picnixz commented Mar 1, 2026

I also think it'd be better as a new feature so that it pairs well with what we already shipped. Considering it relies on annotationlib, it wouldn't be possible to backport it to 3.13 either so I'd prefer keeping it in 3.15 only.

@johnslavik johnslavik requested a review from AA-Turner as a code owner March 1, 2026 19:36
@johnslavik
Copy link
Member Author

johnslavik commented Mar 1, 2026

Thanks for the careful review, @picnixz :) I've also added a "What's New" entry. Do you think this looks good now?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants