Skip to content

chore:migrate form black to ruff(#916)#1012

Open
sun-9545sunoj wants to merge 1 commit intoquantumlib:mainfrom
sun-9545sunoj:migrate-to-ruff
Open

chore:migrate form black to ruff(#916)#1012
sun-9545sunoj wants to merge 1 commit intoquantumlib:mainfrom
sun-9545sunoj:migrate-to-ruff

Conversation

@sun-9545sunoj
Copy link

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.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added the size: L 250< lines changed <1000 label Feb 2, 2026
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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L 250< lines changed <1000

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant