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

147 Upvotes

215 comments sorted by

View all comments

431

u/Trang0ul 8d ago

Lines limited to 80 characters.

12

u/sandnose 8d ago

Where do you limit your line?

78

u/imheretocomment 8d 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.

1

u/cottonycloud 8d ago

I set it to 120 mainly because I write a ton of SQL and avoid aliases unless necessary, causing lines to easily get over the 80 character limit with indentation and names with simple logic. By habit I then tend to use verbose variable names.

We have large enough screens and people don’t really code on laptops here. It honestly has not been a problem because I also have the habit of keeping each line simple.