Skip to content

gh-141174: Test type_repr() of Template with invalid syntax in Interpolation - #155661

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
dr-carlos:annolib-test-typerepr
Aug 13, 2026
Merged

gh-141174: Test type_repr() of Template with invalid syntax in Interpolation#155661
JelleZijlstra merged 1 commit into
python:mainfrom
dr-carlos:annolib-test-typerepr

Conversation

@dr-carlos

@dr-carlos dr-carlos commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Currently, there is no test in test_annotationlib.py of the following lines:

except SyntaxError:
return _template_to_ast_constructor(template)

These ensure that a reasonable value is returned when stringifying a Template annotation containing invalid syntax.

This could be tested for both get_annotations(format=Format.STRING) and type_repr(). But, it's impossible from a syntactic t-string and only possbile through artificial Template construction, which is only currently tested within the type_repr() tests. So I've only added a test there. Happy to add them in other places if that's required.

@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Aug 13, 2026
@JelleZijlstra JelleZijlstra added skip news needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 13, 2026
@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) August 13, 2026 14:18
@JelleZijlstra
JelleZijlstra merged commit 5cc9e46 into python:main Aug 13, 2026
58 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @dr-carlos for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155711 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2026
JelleZijlstra pushed a commit that referenced this pull request Aug 13, 2026
…x in `Interpolation` (GH-155661) (#155712)

gh-141174: Test `type_repr()` of `Template` with invalid syntax in `Interpolation` (GH-155661)

Test `type_repr()` of `Template` with invalid syntax in `Interpolation`
(cherry picked from commit 5cc9e46)

Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants