Skip to content

build(ruff): align the ruff config with template-python - #431

Merged
furedea merged 4 commits into
mainfrom
build/align-lint-config
Nov 10, 2026
Merged

furedea merged 4 commits into
mainfrom
build/align-lint-config

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

概要

dotfiles の ruff 設定を template-python に揃える (Refs furedea/agent-config#74,cfg-align の dotfiles 行).

設定の変更 (pyproject.toml)

  • select をテンプレートの順序にそろえ,DOC を追加 (違反 0).CPY は template-python 側でも削除済みのため入れない.
  • ignore をテンプレートの一覧に置換し,下表の 18 件を削除.
  • PLR0917 は tests 限定の ignore からグローバルの ignore に移動 (ユーザー判断).理由はコメントで明記.
  • プロジェクト固有の ignore は無い.

削除した ignore の元の理由

元の理由は git log -S で追跡.18 件はすべて 8428059 (2026-05,build(python): bootstrap uv project for hook and script tests) で,当時のスキル用スクリプトを温存するコメント付きで追加された.faa537f (#2) でスクリプトが移設されたときにコメントが落ち,de295d1 (#52) で理由なしで再追加された.保護対象のスクリプト (agents/skills/**/scripts/*.py,run_audit.py など) は faa537f と 83d1a89 (#98) で削除済みで,現在の Python は github/,herdr/,zsh/,tests/ のみ.

削除後,全 18 規則を有効にして全体を検査した結果,違反が出たのは I001,E501,ARG001 のみで,下記のとおり修正済み.

規則 検査内容 元の理由 (8428059 のコメント) 現在は当てはまらない理由
ARG001 未使用の関数引数 "Patch schema keeps current_description for compatibility" 対象の apply_patches.py は削除済み.違反はテストの 1 件のみで,usefixtures に移して修正.
B007 未使用のループ変数 "os.walk tuple names document positional contents in existing code" os.walk を使うコードは存在しない (grep で 0).
C401 set(generator) を内包表記へ "Existing aggregation code favors explicit generator layout" 対象の集計コード (collect_transcripts.py など) は削除済み.違反 0.
DTZ005 tz 無しの datetime.now() "Timestamped local workspace names intentionally use local time" ローカル時刻の作業ディレクトリ名を作る run_audit.py は削除済み.datetime.now() の使用 0.
E402 import がファイル先頭にない "run_audit adjusts sys.path before importing sibling scripts" run_audit.py は削除済み.sys.path を操作するコードは存在しない (grep で 0).
E501 行が 119 桁超 "Embedded HTML/JS templates intentionally preserve long source strings" generate_report.py の HTML/JS テンプレートは削除済み.残りの 6 行はテスト内の fake スクリプトで,分割して修正.
F541 プレースホルダーの無い f-string "Existing report/changelog writes include harmless f-string literals" レポート出力コードは削除済み.違反 0.
FURB110 x if x else y を x or y へ "Existing JSON output code keeps explicit empty-list fallback branches" 対象の JSON 出力コードは削除済み.違反 0.
FURB122 ループ内の write を writelines へ "Existing changelog writes favor straightforward loops" changelog を書くコードは削除済み.違反 0.
FURB162 末尾 Z の手動置換 "Existing timestamp parser normalizes trailing Z explicitly" transcript のタイムスタンプパーサーは削除済み.違反 0.
FURB171 1 要素のタプルでの in "Existing message-type checks use tuple style consistently" message-type 判定のコードは削除済み.違反 0.
I001 import の並び順 "Keep script import blocks stable while sys.path bootstrapping is present" sys.path を操作するスクリプトが無くなり,理由が消えた.15 ファイルを ruff --fix で整列.
PERF401 ループでの append を内包表記へ "Existing batching code favors stepwise mutation for readability" バッチ処理コードは削除済み.違反 0.
PTH os.path 等を pathlib へ "Legacy scripts use os.path; Path migration is a separate refactor" os.path を使うレガシースクリプトは削除済み.現在のコードは pathlib で,違反 0.
PLW2901 ループ変数の上書き "Existing JSONL parser reuses line after stripping whitespace" JSONL パーサーは削除済み.違反 0.
RUF005 リスト連結を展開構文へ "Existing path reconstruction code is clearer with list concatenation" 対象のパス再構築コードは削除済み.違反 0.
UP015 冗長な open のモード指定 "Explicit read/write modes are kept for CLI-script clarity" CLI スクリプトは削除済み.違反 0.
UP017 timezone.utc を datetime.UTC へ "Existing code imports timezone explicitly" timezone を import するコードは存在しない (grep で 0).
PLR0917 (移動) 位置引数の数 (max-args に従う) dcb0709 (#233): "In ruff 0.16.3, PLR0917 (positional args) is stable and follows max-args, so pytest fixtures would add 83 test-only violations." 理由 (pytest のフィクスチャ) は今も有効なので,無視は維持.位置引数の数は全引数数以下で,PLR0913 (max-args = 3) が既に上限を課すため,個別の ignore はグローバルに移動して統一.

元の理由がまだ成り立つ項目は無かったため,復元した ignore は無い.

コード修正 (別コミット)

規則 修正前 修正後 対応
I001 15 ファイル 0 ruff --fix --select I001
E501 6 行 (テスト内の fake スクリプトと文字列) 0 変数の導入・括弧での分割.抑制なし
ARG001 1 (tests/github/test_repo_cli.py の remote) 0 副作用目的のフィクスチャを @pytest.mark.usefixtures("remote") に移し,引数から削除

非自明な修正の設計上の理由:remote は fake gh のリモート環境を用意する副作用のためだけに要求されていたので,usefixtures に移すのが pytest の意図に沿う (未使用引数を _ で隠すより正しい).

確認

  • ruff check / ruff format --check 通過,pytest 164 passed,ty 通過 (pre-commit)
  • ruff の select はテンプレートと同じ並び.ignore はテンプレートの一覧に PLR0917 (理由コメント付き) を加えたもの

🤖 Generated with Claude Code

furedea and others added 2 commits November 10, 2026 18:05
…ument

Sort imports (I001), wrap lines over 119 columns (E501) and request the
`remote` fixture through usefixtures instead of an unused parameter
(ARG001), so the ruff ignores for these rules can be removed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Use the template's select order (add DOC) and ignore list, select PLR0917
explicitly (a preview rule is inactive under explicit-preview-rules) and
ignore it in tests with the reason. Drop the ignores for ARG001, B007,
C401, DTZ005, E402, E501, F541, FURB110, FURB122, FURB162, FURB171, I001,
PERF401, PTH, PLW2901, RUF005, UP015 and UP017.

Refs furedea/agent-config#74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T11:12:30.170033Z
We couldn’t complete this review. Comment @codex review to try again.
6b13982 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary: no findings.

The changes are mechanical: the ruff config now matches template-python, and the code fixes are import sorting, E501 line splits, and moving remote into @pytest.mark.usefixtures. None of them change runtime behavior. The E501 splits keep the \\n escapes inside the fake-script sources, so the generated stubs are the same as before. The test no longer reads the remote fixture's value, so moving it to usefixtures is safe. I also searched for code the newly enabled rules (PTH, DTZ) would flag, such as os.path, bare open() and datetime.now(), and found nothing. I couldn't run ruff in this environment, so I'm relying on the PR's report that the lint passes.

Blocking findings: 0.

Do not select PLR0917 and keep the tests ignore entry as it was, until the
decision on whether PLR0917 is redundant with PLR0913 is made.

Refs furedea/agent-config#74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary: I found no blocking issues.

  • pyproject.toml: the select/ignore changes only change lint configuration. They have no runtime effect.
  • The code changes are behavior-neutral:
    • import reordering (I001)
    • line splitting inside the fake gh/op stub scripts, which are still valid Python and produce the same output
    • moving the side-effect-only remote fixture to @pytest.mark.usefixtures, which keeps the same setup
  • I did not run ruff or pytest locally because command execution was restricted. This review is based on reading the diff, and I relied on the checks reported in the PR description.

No P0–P3 findings.

PLR0917 is stable since ruff 0.16 and adds nothing over PLR0913 at
max-args = 3, because the positional count never exceeds the total count.
Replace the tests-only ignore with a global one.

Refs furedea/agent-config#74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary: no findings.

  • pyproject.toml: select/ignore now match the template. Moving PLR0917 to the global ignore is sound because max-args = 3 with PLR0913 already limits positional args. The tests/** per-file ignore was updated to match.
  • Code changes are mechanical: import sorting, splitting long lines in the embedded fake gh/op scripts and test strings, and moving remote to @pytest.mark.usefixtures. I read the reformatted fake-script bodies and they are still valid Python with unchanged logic. The usefixtures change keeps the fixture's side effects (env and PATH setup).
  • No runtime behavior changes, so no new tests are needed.

Note: I could not run ruff or pytest in this review environment, so I'm relying on the PR's reported results (ruff clean, 164 passed).

@furedea
furedea merged commit 1ee1aab into main Nov 10, 2026
19 of 21 checks passed
@furedea
furedea deleted the build/align-lint-config branch November 10, 2026 12:35
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.

1 participant