Skip to content

gh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format#145756

Open
mschoettle wants to merge 5 commits intopython:mainfrom
mschoettle:patch-1
Open

gh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format#145756
mschoettle wants to merge 5 commits intopython:mainfrom
mschoettle:patch-1

Conversation

@mschoettle
Copy link

@mschoettle mschoettle commented Mar 10, 2026

Uses annotation format FORWARDREF instead of the default VALUE when calling inspect.signature.
STRING also seems to work but affects existing tests that check the signature.

Closes #145754

@bedevere-app
Copy link

bedevere-app bot commented Mar 10, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@mschoettle mschoettle changed the title gh-145754: Update signature retrieval in unittest.mock to use string annotation format gh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format Mar 10, 2026
@JelleZijlstra
Copy link
Member

This change looks right to me, please add a unit test and we'll hopefully get it merged!

@JelleZijlstra JelleZijlstra added the needs backport to 3.14 bugs and security fixes label Mar 10, 2026
@mschoettle mschoettle marked this pull request as ready for review March 10, 2026 16:53
@mschoettle mschoettle requested a review from cjw296 as a code owner March 10, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autospeccing with unittest.mock is less robust with PEP 649

2 participants