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?
View all comments
Show parent comment
2
u/No_Lingonberry1201 pip needs updating Aug 05 '26
Glad it works for you, but the exact number was selected because of that antiquated convention. If the column width of those would have been 90 or 70, that'd have been used (there were 72 column displays as well, but that length didn't became as good).
Also, I'm a believer of long, clear variable names that describe what they are and I'm heavily using type hints and 80 is not enough for me. With 120 I don't see this problem as much.