-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[flake8-errmsg
] Extend EM101
to support byte strings
#18867
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
EM101
to support byte stringsflake8-errmsg
] Extended EM101
to support byte strings
|
Following the recommendation from the error got the CI tests to pass. I'm just a little concerned about the initial failure. |
What was the initial failure? |
crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs
Outdated
Show resolved
Hide resolved
@@ -203,6 +203,26 @@ pub(crate) fn string_in_exception(checker: &Checker, stmt: &Stmt, exc: &Expr) { | |||
} | |||
} | |||
} | |||
// Check for byte string literals. | |||
Expr::BytesLiteral(ast::ExprBytesLiteral { value: bytes, .. }) => { | |||
if checker.settings.rules.enabled(Rule::RawStringInException) { |
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.
I think we should gate this change behind preview as it is an extension of a stable rule
See
ruff/crates/ruff_linter/src/preview.rs
Line 60 in daa385c
pub(crate) const fn is_unicode_to_unicode_confusables_enabled(settings: &LinterSettings) -> bool { |
The CI error suggested this. I believe it is because of Rust's ownership; it only flagged line 208. I just wanted to make sure there was no problem with it. |
You may just need to rebase or merge |
crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs
Outdated
Show resolved
Hide resolved
|
I updated it so the change is gated behind the preview flag. Also, I merged with main. Sorry about the mess with the history; I realized it would have been cleaner to rebase. |
@njhearp I think something went wrong with your merge. The diff contains too many unrelated changes (which should already be on main?). I'm not quite sure what went wrong here. Could you try doing an interactive rebase and only pick your commits? |
7e25e51
to
2253444
Compare
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.
Looks great, thank you!
flake8-errmsg
] Extended EM101
to support byte stringsflake8-errmsg
] Extend EM101
to support byte strings
* main: [ty] Add regression-benchmark for attribute-assignment hang (#18957) [ty] Format conflicting types as an enumeration (#18956) [ty] Prevent union builder construction for just one declaration (#18954) [ty] Infer nonlocal types as unions of all reachable bindings (#18750) [`pyflakes`] Mark `F504`/`F522`/`F523` autofix as unsafe if there's a call with side effect (#18839) [`playground`] Add ruff logo docs link to Header.tsx (#18947) [ty] Reduce the overwhelming complexity of `TypeInferenceBuilder::infer_call_expression` (#18943) [ty] Add subdiagnostic about empty bodies in more cases (#18942) [ty] Move search path resolution to `Options::to_program_settings` (#18937) [`flake8-errmsg`] Extend `EM101` to support byte strings (#18867) Move big rule implementations (#18931) [`pylint`] Allow fix with comments and document performance implications (`PLW3301`) (#18936)
Summary
Fixes #18765
Test Plan
Added test