Conformance: minor update to LiteralString tests#2179
Open
sharkdp wants to merge 1 commit intopython:mainfrom
Open
Conformance: minor update to LiteralString tests#2179sharkdp wants to merge 1 commit intopython:mainfrom
LiteralString tests#2179sharkdp wants to merge 1 commit intopython:mainfrom
Conversation
I ran into this while looking at ty's conformance results. For an expression like `str(1)`, ty infers `Literal["1"]`. It can therefore infer that `some_literal_str + str(1)` is also of type `LiteralString`. The conformance suite asserts the opposite (that the result should be of type `str`), based on the assumption that `str(1)` is definitely of type `str`. The updated code also seems like a readability-improvement to me, as there is now just one way to refer to a non-`LiteralStr` object. The updates here only lead to line-number changes in the results for all type checkers.
AlexWaygood
approved these changes
Feb 16, 2026
carljm
approved these changes
Feb 16, 2026
JelleZijlstra
approved these changes
Feb 16, 2026
rchen152
approved these changes
Feb 16, 2026
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.
I ran into this while looking at ty's conformance results. For an expression like
str(1), ty infersLiteral["1"]. It can therefore infer thatsome_literal_str + str(1)is also of typeLiteralString. The conformance suite asserts the opposite (that the result should be of typestr), based on the assumption thatstr(1)is definitely of typestr.The updated code also seems like a readability-improvement to me, as there is now just one way to refer to a non-
LiteralStrobject (instead of three different expressions).The updates here only lead to line-number changes in the results for all type checkers.