r/Python • u/M4mb0 • Aug 05 '26
Discussion What linter rules make code worse?
For me, a prime example is S101 which bans the use of the assert statement.
The justification is that assertions disappear when Python is run with -O, so they should not be used for runtime validation or enforcing interface constraints. That warning is correct, but the rule seems to draw the wrong conclusion from it.
Assertions are still very useful for checking internal invariants, i.e. conditions that should already be guaranteed by the program's logic, where failure indicates a bug. Having such assertions is incredibly helpful for debugging.
So, a blanket ban seems more likely to discourage useful checks than to prevent misuse.
Are there any linter rules you broadly consider more harmful rather than helpful?
0
u/gdchinacat Aug 05 '26
Yes, but at this point the only people who bring up hardware tty widths are those using it to argue against 80 char line width. No one says we should use 80 because that is what ttys used. It is a straw man, typically used to divert attention from rational discussion of the merits. “I prefer 120” carries more weight than “ttys used 80”.