Repository navigation
Fix is_simple_callable with unresolvable annotations on Python 3.14 - #10069
Open
DylanMerigaud wants to merge 3 commits into
Open
DylanMerigaud wants to merge 3 commits into
DylanMerigaud wants to merge 3 commits into
Conversation
inspect.signature() evaluates annotations on Python 3.14 (PEP 649), so a method annotated with a name imported only under TYPE_CHECKING raised NameError when used as a serializer field source. Ask for FORWARDREF annotations instead, as only parameter kinds and defaults are needed. Refs encode#9959
auvipy
self-requested a review
October 7, 2026 02:39
auvipy
approved these changes
Oct 7, 2026
browniebroke
reviewed
Oct 7, 2026
The Python version cannot change while the process runs, so the check and the dict move to a module level SIGNATURE_KWARGS constant.
Cover a parameter annotated with an undefined name, both with a default (simple callable) and without one (not a simple callable).
browniebroke
approved these changes
Oct 13, 2026
This branch has not been deployed
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
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.
Description
refs #9959
On Python 3.14,
inspect.signature()evaluates annotations (PEP 649). Failing case, withSomeTypeimported underif TYPE_CHECKING::Only parameter kinds and defaults are read, so 3.14+ now uses
annotationlib.Format.FORWARDREF. The new test fails on main and passes here; tox passes on 3.13 and 3.14.I drafted this with Claude Opus 5.5 and read every line of the diff.