handle Union type in string interpolation checker #7763 #7809
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.
The problematic case was
The Union was treated as a single value instead of looking at the types inside
The fix consists in checking each of the union types
Two questions:
TempNode
for each of the sub types and added the current line to keep some context, not sure it's the right way to do it.any()
.I suppose it shouldn't return an error if one of the types matches the formatting arguments, for instance with
Union[Tuple[str, int], Tuple[str, str, str]]
If you confirm, I will have to refactor part of the check in a sub-method