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-145754: Update signature retrieval in unittest.mock to use forwardref annotation format by mschoettle · Pull Request #145756 · python/cpython

Conversation

@mschoettle

@mschoettle mschoettle commented Mar 10, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

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.

  • Issue: Autospeccing with unittest.mock is less robust with PEP 649 #145754

Closes #145754

Sorry, something went wrong.

Uh oh!

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

All reactions
@mschoettle
unittest.mock: Update signature retrieval to use String annotatio…
1342951
…n format
@bedevere-app

bedevere-app Bot commented Mar 10, 2026

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot mentioned this pull request Mar 10, 2026
Autospeccing with unittest.mock is less robust with PEP 649 #145754
Closed
blurb-it Bot and others added 2 commits March 10, 2026 14:57
@blurb-it
📜🤖 Added by blurb_it.
d64ded3
@mschoettle
use forwardref instead
ae68a42
@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
@mschoettle
fix backticks in news entry
71caad2
@JelleZijlstra

JelleZijlstra commented Mar 10, 2026

Copy link
Copy Markdown
Member

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

mschoettle and johnslavik reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@JelleZijlstra JelleZijlstra added the needs backport to 3.14 bugs and security fixes label Mar 10, 2026
@mschoettle
add test
5d9a394
@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
@bedevere-app bedevere-app Bot added the awaiting review label Mar 10, 2026
@epenet epenet mentioned this pull request Mar 11, 2026
Remove 'from __future__ import annotations' home-assistant/core#165306
Closed
1 of 23 tasks
@emontnemery emontnemery mentioned this pull request Mar 11, 2026
Remove 'from __future__ import annotations' in tests home-assistant/core#165301
Closed
1 of 21 tasks
@mschoettle

mschoettle commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

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

Thanks, @JelleZijlstra! I added a unit test. Are you able to review it or does it require @cjw296 as the code owner?

All reactions

Sorry, something went wrong.

Uh oh!

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

JelleZijlstra
JelleZijlstra reviewed Mar 19, 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.

Sorry, looks like I never submitted this review.

I am comfortable merging this once I'm happy with the code.

Sorry, something went wrong.

Uh oh!

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

mschoettle reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/test/test_unittest/testmock/testmock.py Resolved

Uh oh!

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

Comment thread Lib/test/test_unittest/testmock/testmock.py Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Library/2026-03-10-14-57-15.gh-issue-145754.YBL5Ko.rst Resolved

Uh oh!

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

mschoettle and others added 3 commits March 19, 2026 12:15
@mschoettle @JelleZijlstra
Apply suggestions from code review
569deb2
Co-authored-by: Jelle Zijlstra <[email protected]>
@mschoettle
Merge branch 'python:main' into patch-1
78ec3dd
@mschoettle
clean up
a5989fd
@mschoettle
mschoettle requested a review from JelleZijlstra March 19, 2026 17:33
@JelleZijlstra
JelleZijlstra merged commit d357a7d into python:main Mar 20, 2026
47 checks passed

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented Mar 20, 2026

Copy link
Copy Markdown

Thanks @mschoettle for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting review label Mar 20, 2026
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 20, 2026
@mschoettle @miss-islington
pythongh-145754: Update signature retrieval in unittest.mock to use f…
186b50d
…orwardref annotation format (pythonGH-145756)

(cherry picked from commit d357a7d)

Co-authored-by: Matthias Schoettle <[email protected]>
@bedevere-app

bedevere-app Bot commented Mar 20, 2026

Copy link
Copy Markdown

GH-146191 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Mar 20, 2026
@bedevere-bot

bedevere-bot commented Mar 20, 2026

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot x86 Debian Non-Debug with X 3.x (no tier) has failed when building commit d357a7d.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1245/builds/7793) and take a look at the build logs.
  4. Check if the failure is related to this commit (d357a7d) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1245/builds/7793

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/contextlib.py"�[0m, line �[35m85�[0m, in �[35minner�[0m
    return func(*args, **kwds)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m597�[0m, in �[35mtest_interrupt�[0m
    exitcode = self._kill_process(multiprocessing.Process.interrupt)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/contextlib.py"�[0m, line �[35m85�[0m, in �[35minner�[0m
    return func(*args, **kwds)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m578�[0m, in �[35m_kill_process�[0m
    self.assertEqual(�[31mjoin�[0m�[1;31m()�[0m, None)
                     �[31m~~~~�[0m�[1;31m^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m251�[0m, in �[35m__call__�[0m
    return �[31mself.func�[0m�[1;31m(*args, **kwds)�[0m
           �[31m~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/multiprocessing/process.py"�[0m, line �[35m156�[0m, in �[35mjoin�[0m
    res = self._popen.wait(timeout)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/multiprocessing/popen_fork.py"�[0m, line �[35m44�[0m, in �[35mwait�[0m
    return �[31mself.poll�[0m�[1;31m(os.WNOHANG if timeout == 0.0 else 0)�[0m
           �[31m~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/multiprocessing/popen_fork.py"�[0m, line �[35m28�[0m, in �[35mpoll�[0m
    pid, sts = �[31mos.waitpid�[0m�[1;31m(self.pid, flag)�[0m
               �[31m~~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m574�[0m, in �[35mhandler�[0m
    raise RuntimeError('join took too long: %s' % p)
�[1;35mRuntimeError�[0m: �[35mjoin took too long: <Process name='Process-1' pid=12129 parent=12127 started daemon>�[0m


Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/contextlib.py"�[0m, line �[35m85�[0m, in �[35minner�[0m
    return func(*args, **kwds)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m597�[0m, in �[35mtest_interrupt�[0m
    exitcode = self._kill_process(multiprocessing.Process.interrupt)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/contextlib.py"�[0m, line �[35m85�[0m, in �[35minner�[0m
    return func(*args, **kwds)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m578�[0m, in �[35m_kill_process�[0m
    self.assertEqual(�[31mjoin�[0m�[1;31m()�[0m, None)
                     �[31m~~~~�[0m�[1;31m^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m251�[0m, in �[35m__call__�[0m
    return �[31mself.func�[0m�[1;31m(*args, **kwds)�[0m
           �[31m~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/multiprocessing/process.py"�[0m, line �[35m156�[0m, in �[35mjoin�[0m
    res = self._popen.wait(timeout)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/multiprocessing/popen_fork.py"�[0m, line �[35m44�[0m, in �[35mwait�[0m
    return �[31mself.poll�[0m�[1;31m(os.WNOHANG if timeout == 0.0 else 0)�[0m
           �[31m~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/multiprocessing/popen_fork.py"�[0m, line �[35m28�[0m, in �[35mpoll�[0m
    pid, sts = �[31mos.waitpid�[0m�[1;31m(self.pid, flag)�[0m
               �[31m~~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.nondebug/build/Lib/test/_test_multiprocessing.py"�[0m, line �[35m574�[0m, in �[35mhandler�[0m
    raise RuntimeError('join took too long: %s' % p)
�[1;35mRuntimeError�[0m: �[35mjoin took too long: <Process name='Process-158' pid=21989 parent=19679 started daemon>�[0m
All reactions

Sorry, something went wrong.

Uh oh!

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

JelleZijlstra pushed a commit that referenced this pull request Mar 20, 2026
@miss-islington @mschoettle
[3.14] gh-145754: Update signature retrieval in unittest.mock to use …
7ba9580
…forwardref annotation format (GH-145756) (#146191)

gh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format (GH-145756)
(cherry picked from commit d357a7d)

Co-authored-by: Matthias Schoettle <[email protected]>
CuriousLearner added a commit to CuriousLearner/cpython that referenced this pull request Mar 22, 2026
@CuriousLearner
Merge remote-tracking branch 'upstream/main' into fix-pythongh-138577
2691ad9
* upstream/main: (1475 commits)
  Docs: replace all `datetime` imports with `import datetime as dt` (python#145640)
  pythongh-146153: Use `frozendict` in pure python fallback for `curses.has_key` (python#146154)
  pythongh-138234: clarify returncode behavior for subprocesses created with `shell=True` (python#138536)
  pythongh-140947: fix contextvars handling for server tasks in asyncio  (python#141158)
  pythonGH-100108: Add async generators best practices section (python#141885)
  pythonGH-145667: Merge `GET_ITER` and `GET_YIELD_FROM_ITER` (pythonGH-146120)
  pythongh-146228: Better fork support in cached FastPath (python#146231)
  pythongh-146227: Fix wrong type in _Py_atomic_load_uint16 in pyatomic_std.h (pythongh-146229)
  pythongh-145980: Fix copy/paste mistake in binascii.c (python#146230)
  pythongh-146092: Raise MemoryError on allocation failure in _zoneinfo (python#146165)
  pythongh-91279: Note `SOURCE_DATE_EPOCH` support in `ZipFile.writestr()` doc (python#139396)
  pythongh-146196: Fix Undefined Behavior in _PyUnicodeWriter_WriteASCIIString() (python#146201)
  pythongh-143930: Reject leading dashes in webbrowser URLs
  pythongh-145916: Soft-deprecate ctypes.util.find_library (pythonGH-145919)
  pythongh-146205: Check the errno with != 0 in close impls in select module (python#146206)
  pythongh-146171: Fix nested AttributeError suggestions (python#146188)
  pythongh-146099: Optimize _GUARD_CODE_VERSION+IP via function version symbols (pythonGH-146101)
  pythongh-145980: Add support for alternative alphabets in the binascii module (pythonGH-145981)
  pythongh-145754: Update signature retrieval in unittest.mock to use forwardref annotation format (python#145756)
  pythongh-145177: Add emscripten run --test, uses test args from config.toml (python#146160)
  ...
@pablogsal pablogsal mentioned this pull request Apr 4, 2026
gh-130273: Fix traceback color output with unicode characters #142529
Merged
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@mschoettle @ljfp
pythongh-145754: Update signature retrieval in unittest.mock to use f…
ec9558a
…orwardref annotation format (python#145756)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cjw296 cjw296 Awaiting requested review from cjw296 cjw296 is a code owner
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra

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.

Autospeccing with unittest.mock is less robust with PEP 649

Uh oh!

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

3 participants

@mschoettle @JelleZijlstra @bedevere-bot
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.