[ruff] Implement invalid-assert-message-literal-argument (RUF040)#14488
[ruff] Implement invalid-assert-message-literal-argument (RUF040)#14488dylwil3 merged 8 commits intoastral-sh:mainfrom
ruff] Implement invalid-assert-message-literal-argument (RUF040)#14488Conversation
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 |
dylwil3
left a comment
There was a problem hiding this comment.
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
Show resolved
Hide resolved
ruff] Implement non-string-literal-as-assert-message (RUF040)ruff] Implement invalid-assert-message-literal-argument (RUF040)
dylwil3
left a comment
There was a problem hiding this comment.
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 testand review ofruff-ecosystem