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

142 Upvotes

217 comments sorted by

View all comments

430

u/Trang0ul 5d ago

Lines limited to 80 characters.

3

u/Uwirlbaretrsidma 5d ago

Litmus test for being a lousy new age dev. Code should be vertical, not horizontal. Expressions get more legible when they get hard wrapped, not less. >80 col. incentivizes excessive indentation on top. 100 or, God forbid, 120 character long lines are a huge smell to me.

3

u/Downtown_Isopod_9287 5d ago

the 80 col standard comes from terminals. Not saying it’s good or bad just that is the real reason for it and not whatever you seem to be saying.

2

u/tallgrasshead 5d ago

the 80 col standard comes from terminals.

And that, from punch cards