chore:migrate form black to ruff(#916)#1012
Open
sun-9545sunoj wants to merge 1 commit intoquantumlib:mainfrom
Open
chore:migrate form black to ruff(#916)#1012sun-9545sunoj wants to merge 1 commit intoquantumlib:mainfrom
sun-9545sunoj wants to merge 1 commit intoquantumlib:mainfrom
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Contributor
There was a problem hiding this comment.
Code Review
This pull request migrates the project from Black and isort to Ruff, consolidating linting and formatting. No security vulnerabilities were found. However, a critical issue was identified in the check/format-incremental script where a variable is used without being defined. Additionally, there's a potential regression in the isort configuration within pyproject.toml and a minor style guide violation in the new ruff.json problem matcher. Please refer to the detailed comments for specific suggestions.
352dec1 to
5b66e74
Compare
5b66e74 to
a4c1bc7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR transitions the qsim repository from Black to Ruff. This consolidates formatting, linting, and import sorting into a single, high-performance tool, aligning qsim with the standards used in related projects like Cirq.
Main Changes
Configuration:
Updated pyproject.toml to remove [tool.black] and [tool.isort] configurations.
Added [tool.ruff] targeting Python 3.10, including specific isort settings (combine-as-imports, known-first-party).
Development Environment:
Swapped black for ruff in dependencies.
Updated .pre-commit-config.yaml to use Ruff hooks.
Scripts & Automation:
Refactored check/format-incremental to utilize ruff check --fix and ruff format.
CI/CD & UX:
Replaced the legacy black.json problem matcher with a new ruff.json matcher.
Updated .github/workflows/ci.yaml to register the Ruff matcher, ensuring linting errors are annotated directly in the GitHub PR UI.
Verification Performed
Linting/Formatting: Ran check/format-incremental locally; the codebase is now 100% Ruff-compliant.
Package Integrity: Successfully ran python -m pytest --collect-only.
Result: 102 tests collected. This confirms that the reformatting and import sorting did not introduce syntax errors or break the package structure.
CI Logic: Verified the regex in ruff.json matches the output format of the astral-sh/ruff-action.