Adding unified linting/formatting using Ruff#54
Conversation
…revent merge conflicts in the recent PR).
There was a problem hiding this comment.
Pull request overview
This PR introduces Ruff as a unified linting and formatting tool for the codebase to address the issue of inconsistent code reviews caused by numerous formatting changes. The configuration targets Python 3.12 and includes common linting rules along with import sorting.
Key changes:
- Added Ruff configuration with line length of 100, pycodestyle, pyflakes, isort, pyupgrade, and Ruff-specific rules
- Implemented GitHub Actions workflow to automatically check linting and formatting on pushes and PRs to main
- Documented Ruff usage and CI integration in the README
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
ruff.toml |
Configures Ruff with Python 3.12 target, linting rules (E, W, F, I, UP, RUF), isort settings for first-party packages, and per-file ignores for __init__.py and scripts |
.github/workflows/lint-format.yml |
Adds CI workflow to run Ruff linter and formatter checks on pushes and PRs targeting main branch |
README.md |
Adds Development section documenting Ruff commands for manual usage and explaining the GitHub Actions integration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| [lint.per-file-ignores] | ||
| "__init__.py" = ["F401"] # Allow unused imports in __init__.py files | ||
| "scripts/*" = ["T201"] # Allow print statements in scripts |
There was a problem hiding this comment.
The T201 rule (which flags print statements) is being ignored for scripts, but T201 is not included in the select list above. This ignore will have no effect since the rule is not enabled. If you want to allow print statements in scripts while enforcing this rule elsewhere, you need to add "T" (flake8-print) to the select list in the [lint] section.
| - Every push to `main` branches | ||
| - Every pull request targeting `main` branches |
There was a problem hiding this comment.
The phrase "main branches" should be "main branch" (singular) since there is only one main branch being referenced.
| - Every push to `main` branches | |
| - Every pull request targeting `main` branches | |
| - Every push to the `main` branch | |
| - Every pull request targeting the `main` branch |
|
TODO: run the linter and formatter after #53 goes in to avoid causing merge conflicts. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Problem
We need to move to a unified way of linting and formatting on the codebase. It's been difficult to do code reviews when there are hundreds of formatting changes.
What Was Changed
I've setup Ruff and a GitHub Action to check on pushes and for PRs.