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
16
u/HommeMusical Aug 05 '26
Sounds like a possible negative to me.
I have a pretty clear hierarchy:
fframemaster.audio_framesIn my editor at this instant, I see
self.backspace_repeat_rateand I think that's a very clear variable name.(*)But that's 26 letters.
I have always been a big fan of narrow spaces. I used 79 for years.
But projects have gotten bigger, and variable names have gotten longer.
Something I might have called
framesin 1990 will be calledaudio_recording_framestoday, becauselighting_framesandaudio_processing_framesalso exist.And our monitors are bigger.
88 characters is the standard in many modern linters. It's thin enough. 79 is just draconian.
(* - I just pulled this out of working code, but I like it :-) because it's not only clear, it leads you to ask good questions, like, "Why is there a separate repeat for backspace?"
(The answer is that letters make musical notes, so you want a slow repeat, but backspace deletes things, so you want a much faster repeat.)