-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[ruff
] Stabilize pytest-raises-ambiguous-pattern
(RUF043
)
#16657
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 RUF043 and moves its test to the right place. The docs look good. Test Plan -- 0 closed or open issues. 1 follow-up PR to fix typos in the test documentation and 1 bug fix to treat `)` as a regex meta-character on 2025-01-01. This can be a pretty noisy rule (+503 violations in the initial PR), so we'll see how the ecosystem check looks now.
CodSpeed Performance ReportMerging #16657 will degrade performances by 10.81%Comparing Summary
Benchmarks breakdown
|
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF043 | 438 | 438 | 0 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
These all look like true positives and almost all with I'm not totally sure if the number of hits actually decreased or if the truncation is just different. airflow is down 7 violations but ibis and pandas are +1 each. |
Do you mean compared to the initial PR? It's possible that some repositories use preview mode and have fixed the violations in their code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's certainly a more noisy rule and it's unfortunate we can't provide an auto fix (because Ruff can't know what the desired behavior is). But I think it's fine to stabilize
Unless we want to add a heuristic for the auto fix. E.g.:
- A string ending with
.
is probably a sentence -> escape it - A string with a sequence of metacharacters (e.g.
.*
or.+
) is probably a regex -> make it raw. We can limit it to only support some specific patterns.
The first fix would have to be unsafe because it does change the program's semantics. The second one could be safe but I think it's still best to make user explicitly opt-in. We could document the heuristics in the rule and having a fix could reduce the churn for users.
I'd postpone the promotion to stable if the suggested fix does sound reasonable (CC: @AlexWaygood)
I'm going to close this for now and open an issue with Micha's fix idea. The rule is a bit newer than most of the other stabilizations anyway. I'm not opposed to reopening and merging it for v0.10, however. Just don't let me forget to add it back to the blog post! |
Summary
Stabilizes RUF043 and moves its test to the right place. The docs look good.
Test Plan
0 closed or open issues. 1 follow-up PR to fix typos in the test documentation and 1 bug fix to treat
)
as a regex meta-character on 2025-01-07.This can be a pretty noisy rule (+503 violations in the initial PR), so we'll see how the ecosystem check looks now. I'm happy to hold off stabilizing if we think it's too noisy, just wanted to open the PR just in case.