Skip to content

Commit 79d0963

Browse files
committed
add a note about useless vs unnecessary
1 parent 6ddece9 commit 79d0963

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎docs/rule-proposals.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ more idiomatic. Thus, the question prompts you to consider the _primary_ improve
138138
primarily make code simpler are `complexity` lints, those that primarily make code faster or use
139139
less memory are `performance` lints, and those that primarily make code more idiomatic are `style`.
140140

141+
Note that "useless" in the context of a `correctness` rule should be indicative of a mistake. For
142+
example, `useless-exception-statement` (`PLW0133`) flags exceptions that are constructed and never
143+
raised, suggesting that the user forgot to raise or otherwise use them. In contrast, code that is
144+
merely unnecessary but still working as intended may be a better fit for `complexity`, such as
145+
`useless-try-except` (`TRY203`). As described above, if the code is probably not intentional but may
146+
be in certain cases, `suspicious` can also be a good fit.
147+
141148
## Other guidelines
142149

143150
Following these steps should generally ensure that a rule is a good fit for Ruff. A couple of

0 commit comments

Comments
 (0)