-
Notifications
You must be signed in to change notification settings - Fork 227
Remove isort
, black
and flake8
, replace with ruff
#1808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 useruff
formake quality
andmake style
commands, streamlining the development workflow. - Dependency Management: Removed
black
,isort
, andflake8
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
andisort
's sorting logic. Updatedflake8: noqa
andisort: skip_file
markers toruff: 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
-
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. ↩
There was a problem hiding this 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.
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"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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"] |
There was a problem hiding this 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"]
74c7119
to
96b192d
Compare
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 |
Signed-off-by: Fynn Schmitt-Ulms <[email protected]>
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]>
96b192d
to
796a5b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
There was a problem hiding this 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.
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:
pyproject.toml
, removing old configs/updating ruff configs to also check import sortingMakefile
to just callruff
inmake quality
andmake style
black
,flake8
, andisort
from dev dependenciesmake quality
commandflake8: noqa
file wide markers withruff: noqa
(not strictly necessary sinceruff
will respect theflake8: noqa
markers but for cleanliness)isort: skip_file
markersNote: this is builds off changes from #1807