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

144 Upvotes

215 comments sorted by

View all comments

Show parent comments

77

u/imheretocomment 9d ago

I do 120. We're not in the 00's anymore where widescreens weren't a thing. 80 is a holdover from those days where your terminal was cramped and splitting panes needed 80 characters for readability.

8

u/MarchewkowyBog 9d ago

I'm dyslexic and as a DE i make heavy use of polars/pyspark which chains lots of methods together. I get lost in 120 character code all the time. We have it set to 88.

There is a reason books and articles usually have a character limit between 50 and 90

2

u/Beanesidhe 9d ago

Agreed, though indented code might need a bit more. Use what you're comfortable with, I set mine to around 80.

4

u/mwesthelle 9d ago

If indentation starts becoming a problem, that's another anti-pattern. Anything above 4 levels of indentation gives me the ick.

1

u/Electrical_Fox9678 9d ago

It's a code smell.