r/Python • • 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?

150 Upvotes

213 comments sorted by

View all comments

Show parent comment

1

u/AlSweigart Author of "Automate the Boring Stuff" Aug 05 '26

80 is still advantageous when you need to view side-by-side diffs.

And disadvantageous every other time.

2

u/Competitive_Travel16 Aug 05 '26

I like to have stuff I'm not working on (or that I know is working) short under 80, and then use longer lines, with simple comments if need be, to make the places I'm working on longer to stand out when scrolling.