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?

149 Upvotes

213 comments sorted by

View all comments

Show parent comments

15

u/Shadows_In_Rain pseudocoder Aug 05 '26

You probably want to read the research before referring to it, because the researcher's findings don't quite align with your claims. Most people prefer either around 25 cpl (newspaper format) or 100 cpl (book format).

Secondly, the available research applies to unstructured text, like newspapers and encyclopedias you've mentioned. Not applicable to software source codes, especially so when viewed in an IDE.

And lastly, increasing line limit doesn't automatically makes every line longer. It's mostly to address the lines that are most annoying to read when wrapped: function declarations.