Fix unformatted f-string in List type error message#1870
Merged
RobinPicard merged 2 commits intoJun 19, 2026
Conversation
The error raised by `_handle_list` for an invalid number of type
arguments used a plain string literal, so the `{args}` placeholder was
printed verbatim instead of the offending arguments. Make it an f-string
so the message reports the actual args, matching the sibling
`_handle_dict` error.
Also tighten the existing test to assert the args are interpolated.
Contributor
|
Thanks for the fix! |
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.
What
_handle_listinoutlines/types/dsl.pyraises aTypeErrorwhen aListtype is given the wrong number of arguments. The message was built from two
adjacent string literals, and the second one was a plain string rather than an
f-string:
So
{args}was printed literally instead of the actual arguments. For exampleList[int, str]produced:The sibling
_handle_dicta few lines down already uses an f-string(
f"Dict must have exactly two type arguments. Got {args}."), so this justbrings
_handle_listin line with it.After
Tests
test_dsl_handle_listalready exercised this path with a barepytest.raises(TypeError), which passed even with the broken message. Itightened that assertion to
matchthe interpolated args so it fails on theold string and passes on the fix.