Skip to content

lint: replace isort/flake8 with ruff#2992

Open
mike-hunhoff wants to merge 10 commits intomasterfrom
fix/2945
Open

lint: replace isort/flake8 with ruff#2992
mike-hunhoff wants to merge 10 commits intomasterfrom
fix/2945

Conversation

@mike-hunhoff
Copy link
Copy Markdown
Collaborator

Recent versions of setuptools removed the pkg_resources module. Our legacy flake8 plugins required this module, which prevented us from updating our build tools. We migrated to ruff to remove these broken plugins and allow us to use the latest setuptools versions.

closes #2945

Checklist

  • No CHANGELOG update needed
  • No new tests needed
  • No documentation update needed
  • This submission includes AI-generated code and I have provided details in the description.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased) section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces isort and flake8 with Ruff for linting and formatting, updating configuration files, documentation, and project dependencies. The feedback identifies a contradiction in the Ruff configuration where import sorting was accidentally disabled and suggests adding additional rule prefixes to maintain full parity with the previous toolset.

Copy link
Copy Markdown
Collaborator

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

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

this is great!

@github-actions github-actions bot dismissed their stale review April 3, 2026 21:39

CHANGELOG updated or no update needed, thanks! 😄

Comment on lines +65 to +82
"B905", # zip() without an explicit strict= parameter
"UP032", # Use f-string instead of format call
"UP031", # Use format specifiers instead of percent format
"SIM300", # Yoda condition detected (constant before variable)
"SIM108", # Use ternary operator instead of if-else block
"ISC003", # Explicitly concatenated string should be implicitly concatenated
"UP035", # Deprecated typing alias usage
"UP006", # Use type instead of Type for type annotation
"SIM115", # Use a context manager for opening files
"SIM118", # Use key not in dict instead of key not in dict.keys()
"UP024", # Replace aliased errors with OSError
"UP045", # Use X | None for optional type annotations
"SIM103", # Return negated condition directly
"UP007", # Use X | Y for union type annotations
"B904", # Raise exceptions within except clause using raise from
"UP028", # Replace yield over for loop with yield from
"C409", # Unnecessary list comprehension passed to tuple()
"E226", # Missing whitespace around arithmetic operator
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@williballenthin @mr-tz I addressed and removed a number of these already - this is what is left. Most of these require many changes, with little benefit IMO. But I'm happy to address any remaining that we'd like to address in this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm on the edge for "UP035", # Deprecated typing alias usage. It's quite a few changes, but it removes deprecated usage.

@mike-hunhoff
Copy link
Copy Markdown
Collaborator Author

Boo, I was concerned that removing those unused imports was going to break things. I'll take a closer look next week.

@fariss
Copy link
Copy Markdown
Collaborator

fariss commented Apr 3, 2026

Thanks Mike, I also recommend replacing black with ruff for formatting. Ref

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.

CI: replace flake8 and isort in favor of ruff

3 participants