Skip to content

chore: apply ruff 0.17 default-rule auto-fixes - #705

Open
hirosassa wants to merge 1 commit into
masterfrom
chore/ruff-autofix
Open

hirosassa wants to merge 1 commit into
masterfrom
chore/ruff-autofix

Conversation

@hirosassa

Copy link
Copy Markdown
Collaborator

Refs #698 (step 2 of the plan in the thread)

What

Ran ruff check --fix --unsafe-fixes with the ruff 0.17 default rules (the select pin is temporarily removed for the run, and kept in the commit), excluding:

32 files, mostly dict(...) -> literals (C408) in tests. Non-test changes are __all__ sorting (RUF022), isinstance tuple merge, raise e -> raise, removesuffix, __enter__ -> Self, collapsed with / if.

Not in this PR

Manual fixes (PYI036/PYI034, SIM115, RUF012, TC004, ...) and dropping the select pin with the ignore list.

Verification

ruff check, ruff format, pyright (0 errors) and the full pytest suite (873 passed) pass locally.

🤖 Generated with Claude Code

Applies `ruff check --fix --unsafe-fixes` for the new default rules (mostly C408 in tests),
excluding TC004, PIE790 and PLE0704. The `select` pin is kept; it is dropped in a follow-up.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kitagry kitagry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I reproduced the change on the base commit (ed97b07): with the select pin removed, ruff check --fix --unsafe-fixes --extend-ignore TC004,PIE790,PLE0704 followed by ruff format gives exactly this diff, so there are no hand edits to look for. ruff check, ruff format, pyright (0 errors) and pytest -n auto (873 passed) pass locally.

I went through the rewrites that could change behavior one by one, and none does:

  • raise e -> raise (TRY201, task_lock_wrappers.py): the bare raise re-raises the same exception; the only difference is one fewer traceback line.
  • __enter__ -> Self / gokart_deserialize -> Self (PYI034/PYI019): typing only; Self is fine with requires-python >= 3.11.
  • removesuffix('/') (FURB188), .values() (PERF102), isinstance(x, (list, tuple)), all(<generator>), x != y for not x == y, and the collapsed ifs (SIM102/SIM114) keep the same short-circuit order and results.
  • __all__ sorting (RUF022) does not change what is exported.
  • C408: every rewritten dict(...) takes only keyword arguments, so the literals are equivalent.
  • The TC004 fix is not included, so the lazy imports in gcs_config.py / s3_config.py are untouched.

Two nits, neither blocking:

  1. gokart/file_processor/__init__.py: RUF022 sorted __all__ across the group comments, so # Base classes and types / # DataFrame processors / # Common processors now sit above the wrong names. I'd drop the comments (or the follow-up PR can do it).
  2. gokart/parameter.py: after the PYI019 fix, T = TypeVar('T') is no longer used.

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.

2 participants