Skip to content

Conversation

@jvansanten
Copy link
Contributor

@jvansanten jvansanten commented Nov 7, 2025

Keeping imports sorted with one module per line means that no one has to think about where to place new imports.

Also, replace remaining ignore with single-line ignore.

@vbrinnel
Copy link
Member

vbrinnel commented Nov 9, 2025

E401: Multiple imports on one line

I find import os, sys perfectly clear.
Splitting them into separate lines adds noise without improving readability.
For short, obvious imports, the one‑per‑line rule feels unnecessarily rigid.
One‑per‑line imports may help placement but adding a new import is straightforward either way.

I001: Import block un‑sorted or un‑formatted

This is a rule I mostly agree with and try to follow.
Grouping imports by:

  • Standard library
  • Third‑party packages
  • Local application import

does improve clarity and maintainability.
However, enforcing strict alphabetical sorting goes too far.
For example, being forced to swap the order of:

import sys
import io

strikes me as a waste of time. Though I’m willing to get along if need be, since I already enforce the meaningful part of this rule.

SIM102: Nested if statements

This rule is again too rigid.
Nesting can be intentional and valuable.
It can emphasize a staged decision process and make the logic easier to follow.
Flattening conditions doesn’t always improve clarity, at least not in every case I’ve seen.

My view is that these specific rules do not improve code quality.
I’m fully in favor of linters and static typers, I was an early adopter of mypy and strongly support rules that prevent bugs or improve maintainability.
But I advocate relaxing rules that are purely stylistic.
Ruff is configurable by design, we should not treat its stylistic defaults as mandatory.

As for replacing global ignores with single‑line ignores, I think it depends on the rule. Global ignores keep the code cleaner for rules we’ve dropped, while inline ignores make sense for rare exceptions but add clutter if used often.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants