[ruff] Recognize re.prefixmatch (RUF039, RUF055) - #28311
Merged
Merged
Conversation
|
gorewilliams
force-pushed
the
ruf039-ruf055-prefixmatch
branch
from
September 4, 2026 12:13
33f7635 to
7926d73
Compare
ntBre
requested changes
Sep 4, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
Could you please split off the changes around re.Pattern? That's a much larger change than the 3.15-related changes I had planned, and I also don't think this has been requested previously. Such a large expansion of a rule should go through an issue first.
ruff] Recognize re.prefixmatch (RUF039, RUF055)
gorewilliams
force-pushed
the
ruf039-ruf055-prefixmatch
branch
from
September 4, 2026 19:23
7926d73 to
18c73f7
Compare
Contributor
Author
ntBre
reviewed
Sep 4, 2026
gorewilliams
force-pushed
the
ruf039-ruf055-prefixmatch
branch
from
September 4, 2026 19:45
18c73f7 to
04a904a
Compare
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.
Summary
Adds support for Python 3.15’s
re.prefixmatchto:unraw-re-pattern(RUF039)unnecessary-regular-expression(RUF055)RUF055treatsre.prefixmatchlikere.match, replacing plain string patterns withstr.startswithwhen the result is used in a truth-value context.Recognition is independent of the configured target version, while the mdtests use Python 3.15 where the API is available.
Closes part of #28206.
Test Plan
cargo nextest run -p ruff_mdtest --test mdtestcargo nextest run -p ruff_linter rules::ruff::testscargo dev generate-allprekon all changed files