@@ -95,9 +95,9 @@ flowchart TD
9595 A -->|No| C("Too noisy or opinionated?")
9696
9797 C -->|Yes| D["Pedantic"]
98- C -->|No| E("Incorrect, dangerous,<br/>deprecated, or useless ?")
98+ C -->|No| E("Incorrect or deprecated ?")
9999
100- E -->|Yes| F("Definitely wrong<br/>or useless today?")
100+ E -->|Yes| F("Definitely wrong<br/>today?")
101101 F -->|Yes| G["Correctness"]
102102 F -->|No| H["Suspicious"]
103103
@@ -122,29 +122,22 @@ A large number of diagnostics doesn't immediately make a rule `pedantic`, but ma
122122or diagnostics that reasonable Python users would disagree with do.
123123
124124If a rule is not overly pedantic, we next consider the intention of the rule. If the main goal is
125- detecting code that is obviously incorrect or useless , the options narrow to ` correctness ` or
126- ` suspicious ` . Rules in the ` correctness ` category typically cause immediate issues like syntax or
127- runtime errors, or silently do something the user didn't intend. Similarly, ` suspicious ` lints flag
128- the same kind of code, but in cases where Ruff can't be sure what the user intended. A perfect
129- example of a ` suspicious ` rule is ` mutable-argument-default ` (` B006 ` ). This classic footgun is
130- almost always a mistake, but in some cases, it may be
131- intentional, in which case a ` noqa ` or ` ruff: ignore ` comment should be used. Such suppression
132- comments should essentially never be reasonable for a ` correctness ` lint but are fine for
133- ` suspicious ` lints .
125+ detecting code that is incorrect, the options narrow to ` correctness ` or ` suspicious ` . Rules in the
126+ ` correctness ` category typically cause immediate issues like syntax or runtime errors, or silently
127+ do something the user didn't intend. Similarly, ` suspicious ` lints flag the same kind of code, but
128+ in cases where Ruff can't be sure what the user intended. A perfect example of a ` suspicious ` rule
129+ is ` mutable-argument-default ` (` B006 ` ). This classic footgun is almost always a mistake, but in some
130+ cases, it may be intentional, in which case a ` noqa ` or ` ruff: ignore ` comment should be used. Such
131+ suppression comments should essentially never be reasonable for a ` correctness ` lint but are fine
132+ for ` suspicious ` lints. The ` suspicious ` category also includes deprecations, which aren't incorrect
133+ today but will cause errors in the future .
134134
135135The final branch of the flow chart deals with stylistic lints, which are again somewhat subjective
136136to differentiate between changes that make code simpler often also make the code faster and
137137more idiomatic. Thus, the question prompts you to consider the _ primary_ improvement. Rules that
138138primarily make code simpler are ` complexity ` lints, those that primarily make code faster or use
139139less 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-
148141## Other guidelines
149142
150143Following these steps should generally ensure that a rule is a good fit for Ruff. A couple of
0 commit comments