chore: use tuple in stdout.re_match_lines #919
Merged
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
This was spotted when trying to enforce pyupgrade rules in ruff, and rule UP034 was causing issues: https://docs.astral.sh/ruff/rules/extraneous-parentheses/
Sometimes the first argument was a tuple
stdout.re_match_lines(("a","b"))
, sometimes it was a raw stringstdout.re_match_lines("a")
, and other times it was a bracketed raw stringstdout.re_match_lines(("a"))
Instead of simply converting the bracketed raw string into non-bracketed raw strings, I think it makes better sense to convert all the raw strings to tuples, as
result.stdout.re_match_lines
is supposed to have aSequence[str]
as first argument:Related Issues
Checklist
Additional Comments
This is not picked up by
mypy
as strings are also a sequence of single-character strings.Also, raw strings work behind the scene as they go through
_getlines
which converts them to a sequence.