Skip to content

Replace flake8 with ruff for linting#203

Merged
beniroquai merged 5 commits intomasterfrom
copilot/update-github-action-to-ruff
Jan 2, 2026
Merged

Replace flake8 with ruff for linting#203
beniroquai merged 5 commits intomasterfrom
copilot/update-github-action-to-ruff

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 2, 2026

Migrates code linting from flake8 to ruff as requested.

Changes

  • Configuration: Added [tool.ruff] section to pyproject.toml with equivalent settings from .flake8 (line length 100, complexity 10, excluded directories, per-file ignores)
  • GitHub Actions: Updated imswitch-test.yml to install and run ruff instead of flake8
    • Critical check: ruff check . --select=E9,F821,F822,F823 (syntax errors and undefined names, fails build)
    • Full check: ruff check . --exit-zero (all configured rules as warnings)
  • Cleanup: Removed .flake8 configuration file

Rule Selection

The original flake8 command used --select=E9,F63,F7,F82 which are flake8-specific prefixes. Ruff uses explicit codes:

  • E9: Syntax errors (E902-E999)
  • F821-F823: Undefined names, unassigned local variables

The second ruff check runs all configured rules (E, F, W, C90) with --exit-zero to catch remaining issues as warnings.

Original prompt

This section details on the original issue you should resolve

<issue_title>Introducing RUFF</issue_title>
<issue_description>We want to remove flake8 and want to use ruff for code formatting instead. For this we want to update the github action .github/workflows/imswitch-test.yml</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 2, 2026 15:24
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Co-authored-by: beniroquai <4345528+beniroquai@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace flake8 with ruff for code formatting Replace flake8 with ruff for linting Jan 2, 2026
Copilot AI requested a review from beniroquai January 2, 2026 15:32
@beniroquai beniroquai marked this pull request as ready for review January 2, 2026 15:45
Copilot AI review requested due to automatic review settings January 2, 2026 15:45
@beniroquai beniroquai merged commit 9be7fe1 into master Jan 2, 2026
4 of 16 checks passed
@beniroquai beniroquai deleted the copilot/update-github-action-to-ruff branch January 2, 2026 15:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the project's linting infrastructure from flake8 to ruff, modernizing the tooling while maintaining equivalent rule coverage. The migration includes configuration transfer, CI workflow updates, and cleanup of deprecated files.

Key Changes:

  • Migrated all flake8 configuration settings to ruff in pyproject.toml (line length, complexity, exclusions, per-file ignores)
  • Updated GitHub Actions workflow to use ruff instead of flake8 for linting checks
  • Removed the .flake8 configuration file as it's no longer needed

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pyproject.toml Added [tool.ruff] configuration with equivalent settings from .flake8 including exclusions, line length (100), complexity (10), and rule selection
.github/workflows/imswitch-test.yml Updated CI workflow to install and run ruff with critical error checks and full linting with warnings
.flake8 Removed deprecated flake8 configuration file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment on lines +146 to +147
per-file-ignores = {"__init__.py" = ["F401"]}

Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The per-file-ignores syntax is incorrect for TOML. The current syntax uses {"__init__.py" = ["F401"]} which is not valid TOML. The correct syntax should be "__init__.py" = ["F401"] (without the curly braces) or use the inline table syntax with commas. Ruff expects this to be a table/mapping, not a dict-within-a-dict.

Suggested change
per-file-ignores = {"__init__.py" = ["F401"]}
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
# F821-F823: Undefined names (most critical Pyflakes errors)
ruff check . --select=E9,F821,F822,F823 --output-format=full
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The rule selection may be too narrow. The original flake8 command used --select=E9,F63,F7,F82 which selected all codes starting with those prefixes (e.g., F63 includes F630-F639, F7 includes F700-F799, F82 includes F820-F829). The new command only selects F821,F822,F823, potentially missing other critical errors like F631 (assert tuple), F701 (break outside loop), F702 (continue outside loop), F704 (yield outside function), and others. Consider using a broader selection like --select=E9,F63,F7,F82 which ruff also supports, or explicitly add the important F6xx and F7xx codes.

Suggested change
# F821-F823: Undefined names (most critical Pyflakes errors)
ruff check . --select=E9,F821,F822,F823 --output-format=full
# F63, F7, F82: Critical Pyflakes errors (e.g., assert tuple, break/continue/yield outside loop/function, etc.)
ruff check . --select=E9,F63,F7,F82 --output-format=full

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introducing RUFF

3 participants