-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[ruff
] Stabilize unraw-re-pattern
(RUF039
)
#16644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary -- Stabilizes RUF039 and moves its tests out of `preview_rules`. Test Plan -- 2 closed issues 3 days after the rule was added, otherwise no issues. However, there's a chance we need a better autofix for regexes involving escapes. We'll need to see the ecosystem check for this.
CodSpeed Performance ReportMerging #16644 will degrade performances by 12.73%Comparing Summary
Benchmarks breakdown
|
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF039 | 223 | 223 | 0 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
The first rasa case is pretty annoying (it looks like @MichaReiser flagged this in the original PR too): It involves an implicitly-concatenated string, so it gets 10 instances of RUF039 in the same snippet. 8 of them involve Unicode escapes ( superset has some implicitly-concatentated strings with multiple diagnostics too. I'm not sure if we can handle this better, and these are auto-fixable at least. Almost all of the gpt_academic cases have escapes and no auto-fixes. bokeh is mostly auto-fixable but has one concatenated string with 4 diagnostics. SummaryI looked at all of the results in the comment, and I would say that the majority have an auto-fix. I think getting multiple diagnostics for implicitly-concatenated strings is probably the most annoying aspect, but I don't think we can do much about that, short of joining the string, which doesn't seem right at all. |
I think |
We could create a signal diagnostic with a single fix for all parts but it has the downside that we couldn't provide a fix if any of the parts aren't autofixable, but that's probably desired to avoid creating strings with mixed normal and raw string parts. We could also make the raw string autofix understand which escape sequences are supported in regex.compile, so that the majority of regex patterns becomes autofixable. @InSyncWithFoo what are the improvements you have in mind? Holding back on this rule and creating a follow up issue does make sense to me |
Not anything concrete yet, but I think it is possible to merge the diagnostics for implicitly concatenated string parts when they are the same (fixes, applicability). The fix could use some work too. |
Sounds good, I can close this for now. @InSyncWithFoo do you want to open the issue to track follow-up work? I'm happy to if not. |
I think I'll do that tomorrow, once I'm done with what I'm currently doing. |
Summary
Stabilizes RUF039 and moves its tests out of
preview_rules
.Test Plan
2 closed issues 3 days after the rule was added, otherwise no issues. However, there's a chance we need a better autofix for regexes involving escapes. We'll need to see the ecosystem check for this.