-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ruff
] Implement invalid-assert-message-literal-argument
(RUF040
)
#14488
[ruff
] Implement invalid-assert-message-literal-argument
(RUF040
)
#14488
Conversation
ruff
] Implement non-string-literal-as-assert-message
(RUF035
)ruff
] Implement non-string-literal-as-assert-message
(RUF040
)
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF040 | 11 | 11 | 0 | 0 | 0 |
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.
This is a really clever rule idea, and the ecosystem checks all look like genuine bugs - great job! (May be worth filing some issues in those repos, actually 😄 )
I just have a quibble with the name of the rule (see the comment below), and a question about bytes literals, but otherwise this looks awesome. Thank you!
crates/ruff_linter/src/rules/ruff/rules/non_string_literal_as_assert_message.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/non_string_literal_as_assert_message.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/non_string_literal_as_assert_message.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/non_string_literal_as_assert_message.rs
Outdated
Show resolved
Hide resolved
ruff
] Implement non-string-literal-as-assert-message
(RUF040
)ruff
] Implement invalid-assert-message-literal-argument
(RUF040
)
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.
LGTM, thanks for the great contribution!
Thank you for your guidance. |
Very helpful - thanks for the heads up @Lokejoke and team :D apache/airflow#44460 is coming in Airflow. BTW, Some of them were not really "bugs" (i.e. when we had both assert with == and literal added after , but it was good to fix those anyway (True as message printed when assert fails is rather useless hint). |
Summary
This PR implements new rule discussed here.
In short, it searches for assert messages which were unintentionally used as a expression to be matched against.
Test Plan
cargo test
and review ofruff-ecosystem