Skip to content

Conversation

@rolandwalker
Copy link
Contributor

Description

  • let lint target the oldest supported Python version
  • disable lint rules which may conflict with the formatter, per Astral recommendations, and document
  • establish rules for sorting imports (but don't activate this yet in CI)
  • enable preview mode for "ruff format", and reformat code, making some whitespace tighter

Enabling preview = true for ruff might be controversial, but I've had only good luck with it.

The ignored lint rules wouldn't be needed by default, but the "E" and "W" series are explicitly activated.

Checklist

  • I've added this contribution to the changelog.md. already covered
  • I've added my name to the AUTHORS file (or it's already there).

@rolandwalker rolandwalker requested a review from amjith April 24, 2025 11:38
@rolandwalker rolandwalker self-assigned this Apr 24, 2025
Copy link
Member

@amjith amjith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan of not bothering with exceptions and going with the defaults and let ruff check --fix do the work. I realize we need a minimal set of exceptions for conflicting rules. Other than that we can go all in.

pyproject.toml Outdated
'F541', # f-string without placeholders
'PIE808', # range() starting with 0
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
'E501', # Line too long
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think E501 is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it in this PR, but the point is that sometimes ruff check and ruff format have different opinions about the line length. We can always add it back if there is friction.

pyproject.toml Outdated
'E401', # Multiple imports on one line
'E402', # Module level import not at top of file
'E501', # Line too long
'F541', # f-string without placeholders
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove F541 as well and fix all the places that violate this rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. F541 was an intentional style choice. I think there is nothing wrong with f-strings lacking placeholder.

 * let lint target the oldest supported Python version
 * disable lint rules which may conflict with the formatter, per Astral
   recommendations, and document
 * establish rules for sorting imports (but don't activate this yet in
   CI)
 * enable preview mode for "ruff format", and reformat code, making some
   whitespace tighter
@rolandwalker rolandwalker force-pushed the RW/incrementally-improve-linting-setup branch from e6f92b3 to 02baf65 Compare April 25, 2025 11:26
@rolandwalker
Copy link
Contributor Author

rolandwalker commented Apr 25, 2025

Other than that we can go all in.

We are already going further than "all in" by enabling some non-default lint series. However, we aren't enabling ruff check in CI yet because we aren't near passing.

@rolandwalker rolandwalker merged commit 6457b3a into main Apr 25, 2025
6 checks passed
@rolandwalker rolandwalker deleted the RW/incrementally-improve-linting-setup branch April 25, 2025 11:29
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