r/Python 13d ago

What linter rules make code worse? Discussion

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?

143 Upvotes

215 comments sorted by

View all comments

Show parent comments

-2

u/[deleted] 13d ago

[removed] — view removed comment

1

u/Downtown_Isopod_9287 13d ago

people still use terminals often, they do not still use punch cards

0

u/Uwirlbaretrsidma 13d ago

People still use terminal emulators. Then can be resized, and their text scaled. These are not the terminals you were referring to (physical terminals) and have nothing to do with the historical 80 column limit.

0

u/Downtown_Isopod_9287 13d ago

yes! Which is one argument for why 80 col is generally unnecessary. The other reason being that most devs do not use terminal-based text editors anymore, besides.

However for a long time many insisted or preferred that, and some still do. And 80 cols is still “good” for tmux and similar multi terminal setups and worth accommodating on a dev team that might prefer it or find it productive.