Skip to content

Conversation

fynnsu
Copy link
Collaborator

@fynnsu fynnsu commented Sep 10, 2025

SUMMARY:
Ruff supports import sorting, formatting, and linting. We already use if for formatting (black is listed as a dev dependency but isn't used) and linting.

In this pr:

  • 6af05b1
    • Cleans up pyproject.toml, removing old configs/updating ruff configs to also check import sorting
    • Updates Makefile to just call ruff in make quality and make style
    • Removes black, flake8, and isort from dev dependencies
    • Updates dev docs description of make quality command
  • 796a5b8
    • Replaces flake8: noqa file wide markers with ruff: noqa (not strictly necessary since ruff will respect the flake8: noqa markers but for cleanliness)
    • Removes unnecessary isort: skip_file markers

Note: this is builds off changes from #1807

Copy link
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.

Summary of Changes

Hello @fynnsu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly simplifies the project's code quality toolchain by consolidating isort, black, and flake8 into a single, more efficient tool: ruff. This change aims to reduce complexity in development setup and maintenance, ensuring a more consistent and streamlined approach to code formatting and linting across the repository. The update also includes necessary code adjustments to align with the new tool's standards.

Highlights

  • Toolchain Simplification: Replaced multiple code quality tools (isort, black, flake8) with a single, unified tool, ruff, which handles import sorting, formatting, and linting.
  • Build System Updates: Modified the Makefile to use ruff for make quality and make style commands, streamlining the development workflow.
  • Dependency Management: Removed black, isort, and flake8 from development dependencies, reducing project overhead and potential conflicts.
  • Codebase Refactoring: Applied automatic import sorting fixes across numerous Python files due to slight differences between ruff and isort's sorting logic. Updated flake8: noqa and isort: skip_file markers to ruff: noqa for consistency.
  • Documentation Alignment: Updated developer documentation to reflect the change in code styling tools.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 effectively replaces isort, black, and flake8 with ruff for linting, formatting, and import sorting. The changes are well-structured, updating the Makefile, pyproject.toml, and setup.py to reflect the new tooling. The documentation has also been updated accordingly. The automatic import reordering across the example and test files is a direct result of this change.

My main feedback is a suggestion to improve the ruff configuration in pyproject.toml to correctly identify first-party modules. This will ensure that import sorting is done correctly, separating your project's modules from third-party libraries. This is a common configuration point when migrating to ruff and will improve code style consistency.

Comment on lines +9 to 12
extend-exclude = ["env", "src/llmcompressor/transformers/tracing/", "src/llmcompressor/version.py"]
line-length = 88
lint.select = ["E", "F", "W", "I"]
lint.extend-ignore = ["E203", "W605"]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To ensure ruff correctly identifies first-party modules and sorts imports properly, you should specify the source directory. This will help distinguish your project's modules (llmcompressor) from third-party libraries.

Please add src = ["src"] to your [tool.ruff] configuration. After this change, you'll need to run make style again to apply the correct import order across the project.

Suggested change
extend-exclude = ["env", "src/llmcompressor/transformers/tracing/", "src/llmcompressor/version.py"]
line-length = 88
lint.select = ["E", "F", "W", "I"]
lint.extend-ignore = ["E203", "W605"]
src = ["src"]
extend-exclude = ["env", "src/llmcompressor/transformers/tracing/", "src/llmcompressor/version.py"]
line-length = 88
lint.select = ["E", "F", "W", "I"]
lint.extend-ignore = ["E203", "W605"]

Base automatically changed from fynnsu/qmutvpkpntnl to main September 10, 2025 21:37
Copy link
Collaborator

@brian-dellabetta brian-dellabetta left a comment

Choose a reason for hiding this comment

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

isort is moving transformers below llmcompressor in the imports ordering now. We should update so that llmcompressor always come last. This can be done by adding to the pyproject.toml:

[tool.isort]
known_first_party = ["compressed_tensors", "llmcompressor"]

@fynnsu fynnsu force-pushed the fynnsu/uuskqsolovtx branch from 74c7119 to 96b192d Compare September 11, 2025 13:35
@fynnsu
Copy link
Collaborator Author

fynnsu commented Sep 11, 2025

isort is moving transformers below llmcompressor in the imports ordering now. We should update so that llmcompressor always come last. This can be done by adding to the pyproject.toml:

[tool.isort]
known_first_party = ["compressed_tensors", "llmcompressor"]

Yeah this is a good point. I've added

[tool.ruff.lint.isort]
known-first-party = ["llmcompressor", "compressed_tensors"]

Note: that this is still a change because compressed_tensors was previously not considered first party. So a lot of the compressed_tensors imports moved down but I think that's probably what we want.

Not entirely necessary as ruff will also respect the `flake8: noqa` markers but probably better to update these as flake8 is no longer used in the repo

Signed-off-by: Fynn Schmitt-Ulms <[email protected]>
@fynnsu fynnsu force-pushed the fynnsu/uuskqsolovtx branch from 96b192d to 796a5b8 Compare September 11, 2025 16:05
@fynnsu fynnsu added the ready When a PR is ready for review label Sep 11, 2025
Copy link
Collaborator

@brian-dellabetta brian-dellabetta left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

Copy link
Collaborator

@kylesayrs kylesayrs 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 fine with this in principle, as long as you feel that you have a good understanding of ruff enough to maintain an issues that may arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready When a PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants