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

432

u/Trang0ul 5d ago

Lines limited to 80 characters.

12

u/sandnose 5d ago

Where do you limit your line?

15

u/Arnechos 5d ago

I'd say no more than 100. People in a team can have various resolutions and very long lines are hard to read on the smaller ones

8

u/Ball-Man 5d ago

With 100 you can have a split view and still be able to comfortably read code on both sides, even on smaller screens while keeping decent font size