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 — gh-84644: Fix singledispatch annotation parsing by johnslavik · Pull Request #143465 · python/cpython

Conversation

@johnslavik

@johnslavik johnslavik commented Jan 6, 2026 •
edited
Loading

Uh oh!

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

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.

Sorry, something went wrong.

Uh oh!

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

trag1c reacted with eyes emoji
All reactions
  • 👀 1 reaction
johnslavik added 6 commits January 6, 2026 04:43
@johnslavik
Resolve first positional param, required to be annotated
d3d6e64
@johnslavik
Special-case strings for forward refs similarly to typing
6ea2a4a
@johnslavik
Rename ref_or_type to ref_or_typeform
0a39278
@johnslavik
Add comment
096fc3b
@johnslavik
Shorten error message string line
c8a5cdc
@johnslavik
Adjust formatting to functools style
e1cde59
@johnslavik johnslavik added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Jan 6, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jan 6, 2026
functools.singledispatch doesn't verify annotation is on FIRST parameter #84644
Open
johnslavik
johnslavik commented Jan 6, 2026
View reviewed changes
Comment thread Lib/functools.py Resolved

Uh oh!

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

@johnslavik johnslavik mentioned this pull request Jan 6, 2026
gh-127750: Restore inspect and pydoc support of singledispatchmethod #130309
Merged
johnslavik added 5 commits January 6, 2026 08:44
@johnslavik
Normalize None to a type, strip annotations
6bc698b
@johnslavik
Rename ref_or_typeform to fwdref_or_typeform
4ef7c7c
@johnslavik
Rename skip_first to skip_first_param
004c852
@johnslavik
Add news entry
9bc1436
@johnslavik
Add pythonGH-130827 test
3115fd7
@johnslavik

This comment was marked as resolved.

Sign in to view
johnslavik added 2 commits January 6, 2026 09:47
@johnslavik
Fix test
f6c102f
@johnslavik
Remove the get_annotations dance for now
7968570
johnslavik
johnslavik commented Jan 6, 2026
View reviewed changes
Comment thread Lib/functools.py Resolved

Uh oh!

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

johnslavik
johnslavik commented Jan 6, 2026
View reviewed changes
Comment thread Lib/functools.py Resolved

Uh oh!

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

johnslavik added 9 commits January 7, 2026 16:12
@johnslavik
Fix incorrect regster() calls in `TestSingleDispatch.test_method_si…
a808a1e
…gnatures`

See python#130309 (comment)
@johnslavik
Fix string signatures accordingly
69b9978
@johnslavik
Raise exception if positional argument not found
ebdb68d
@johnslavik
Break the exception chain
8d86f9e
@johnslavik
Support all callables
82616f9
@johnslavik
Clarify comment
c9a1f1a
@johnslavik
Fiat lux, inline validation
e878207
@johnslavik
Add more test cases (mainly wrappers)
d3240a3
@johnslavik
More comments!
9240b0d
@johnslavik

johnslavik commented Jul 20, 2026 •
edited
Loading

Uh oh!

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

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.)

All reactions

Sorry, something went wrong.

Uh oh!

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

johnslavik
johnslavik commented Jul 20, 2026
View reviewed changes
Comment thread Lib/functools.py Resolved

Uh oh!

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

@read-the-docs-community

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

Uh oh!

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33748676 | 📁 Comparing b0ae4d1 against main (1f649fe)

  🔍 Preview build  

20 files changed · ± 20 modified

± Modified

  • c-api/type.html
  • deprecations/index.html
  • deprecations/pending-removal-in-3.18.html
  • library/annotationlib.html
  • library/asyncio-subprocess.html
  • library/csv.html
  • library/ctypes.html
  • library/exceptions.html
  • library/functools.html
  • library/logging.handlers.html
  • and 10 more...
All reactions

Sorry, something went wrong.

Uh oh!

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

@johnslavik
johnslavik requested a review from picnixz July 21, 2026 02:13
johnslavik added 2 commits July 24, 2026 20:41
@johnslavik
Make warning clearer
0d0702e
@johnslavik
Use __file__ for path skipping
b0ae4d1
encukou
encukou reviewed Jul 29, 2026
View reviewed changes
Comment thread Doc/deprecations/pending-removal-in-3.18.rst Resolved

Uh oh!

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

Comment thread Doc/library/functools.rst Resolved

Uh oh!

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

JelleZijlstra
JelleZijlstra reviewed Aug 29, 2026
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

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.

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

Sorry, something went wrong.

Uh oh!

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

johnslavik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@johnslavik

johnslavik commented Aug 30, 2026 •
edited
Loading

Uh oh!

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

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).

All reactions

Sorry, something went wrong.

Uh oh!

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

@encukou

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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@johnslavik
Address the review comments
bd65350
@johnslavik johnslavik added the sprint label Oct 20, 2026
@github-project-automation github-project-automation Bot added this to Sprint Oct 20, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint Oct 20, 2026
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Sprint Oct 20, 2026
@johnslavik johnslavik removed the needs backport to 3.13 only security fixes label Oct 20, 2026
@encukou 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

encukou commented Oct 20, 2026

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

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

encukou
encukou previously approved these changes Oct 20, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Oct 20, 2026
@encukou
encukou dismissed their stale review October 20, 2026 17:11

I was too quick :/

encukou
encukou reviewed Oct 20, 2026
View reviewed changes
Comment thread Doc/library/functools.rst Resolved

Uh oh!

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

@johnslavik
Dedupe docs
37cd5a3
@rhettinger
rhettinger removed their request for review October 20, 2026 18:50
encukou
encukou approved these changes Oct 21, 2026
View reviewed changes
@encukou
encukou merged commit 641ef0a into python:main Oct 21, 2026
97 of 99 checks passed

Uh oh!

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

@github-project-automation github-project-automation Bot moved this from In Progress to Done in Sprint Oct 21, 2026
@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 21, 2026
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
@encukou encukou encukou approved these changes
@jaraco jaraco jaraco approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
@picnixz picnixz Awaiting requested review from picnixz

Uh oh!

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

Assignees

No one assigned

Labels

sprint

Projects

Sprint
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

6 participants

@johnslavik @picnixz @encukou @JelleZijlstra @jaraco @pR0Ps
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.