Repository navigation
build: run the agent source on Python 3.15.1 - #26
Merged
Merged
Conversation
nixpkgs ships Python 3.15.0, which has a certificate-handling vulnerability fixed in 3.15.1, and uv 0.11.x or 0.13.0, which predate the managed CPython releases the bootstrap installs. Build both here, independent of dotfiles, for the hook shebangs and the devShell. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Pin the uv installer to 0.13.5 and stop when an installed uv is older, because older uv cannot install the managed CPython the script requests. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
UV_LOCKED makes every uv run and sync fail on a uv.lock mismatch, which --frozen never checked. Pin uv 0.13.5 and Python 3.15.1 in setup-uv so CI matches the devShell. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
requires-python becomes >= 3.15.1, < 3.16, and .python-version names the minor only: the exact patch comes from Nix, today the own 3.15.1 build. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ment Strip a pre-release or local suffix before comparing uv versions, keep UV_VERSION and PYTHON_VERSION from the caller out of the bootstrap tests, and drop the remaining 3.14 mentions from comments. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
nixpkgs has no binary cache for the own CPython 3.15.1, so every job that enters the devShell compiles it; bats and shell-lint took 8 of their 10 minutes. Drop the extra time once nixpkgs ships 3.15.1. Refs #23 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
3 tasks done
furedea
added a commit
that referenced
this pull request
Nov 15, 2026
) Refs #74(Python レーン) Refs #196 計画: #74 (comment) ## 概要 **最終方針(ユーザー決定)**: 静的な ast-grep 規則は linter の error と同じく止める(`severity: error`).残すのは `py_no_nonlocal`,`py_no_pytest_asyncio`,`py_async_test_anyio_marker`(`anyio` を完全一致で判定),`py_no_unittest`,`py_no_unittest_mock`,`py_xfail_requires_strict`,`py_mocker_patch_autospec`,`py_no_staticmethod`,`py_dataclass_slots`,`py_plain_class_slots` と新規 4 規則.`py_logging_dict_message`,`py_loop_variable_descriptive`,`py_definition_order`,`py_frozen_config_complete` は規則と例のテストと文章を削除した.`py_no_pytest_asyncio` は `pytest.mark.asyncio` と `pytest_asyncio` の import だけに絞った.まれな例外は,レビュー済みの suppression コメントで通す. `python-style` skill の文章規則を 1 規則ずつ棚卸しし,最も安い判定手段へ移した(ADR-0020,ADR-0021). - 既存 linter(ruff)が既に覆う文章は削除し,対応する規則 ID を表に書いた. - ast-grep 規則を 8 件追加し,`rule-tests` を各規則に valid / invalid 各 3 件以上付けた. - jev-lint 規則(`model-rules/python/`)を 7 件追加した.文章は ADR-0021 に従い残す.fixtures,eval の当てはめ,baseline は延期(ユーザー指示). - 規則で置き換わらない文章,文脈が必要な文章は文章のまま残した. - 方針(更新): 新しいプロジェクトは `furedea/template-*` からだけ作る.template の `main` で有効な linter 規則が完全に覆う文章は削除し,規則 ID を表に書く.重複する ast-grep 規則 `py_prefer_strenum`(`UP042` と重複)は規則とテストごと削除した.覆われない部分(例外,理由,直し方)は残す. 共有ファイルの変更は `tests/test_model_rule_files.py` だけ(Python の比較を `RULE_IDS` の 3 件に限る変更と,新しい 7 件の subject 数を固定するテスト `test_python_style_model_rules_select_the_subjects_they_ask_about` の追加).`test_python_rules_select_the_functions_they_ask_about` が Python の規則 3 件の subject 数を完全一致で比較していたため,新しい Python 規則が別の subject(fixture,import,値オブジェクトなど)を選ぶと失敗する.比較を既存の `RULE_IDS` の 3 件に限った.他レーンが同じ関数を編集した場合は,マージ時に同じ方針で解消する. ## 文章と規則の対応表 「元の場所」は `agents/skills/python-style/` からの相対パス.ast-grep の実装は `agents/hooks/lint/rules/python/`,例のテストは `agents/hooks/lint/rule-tests/`,jev-lint の実装は `agents/hooks/lint/model-rules/python/<id>/rule.yml`. | 規則 ID | 元の場所 | 元の規則(原文) | 判定 | 実装 | 例のテスト | 元の文章 | | --- | --- | --- | --- | --- | --- | --- | | `py_no_nonlocal` | references/code_style.md(Functions) | Don't use `global`, `nonlocal` | 静的(ast-grep).`global` は既存 linter(ruff `PLW0603`) | `py_no_nonlocal.yml` | 良 2 / 悪 2 | 削除(`nonlocal` は本規則,`global` は template-python の ruff `PLW0603` が置換) | | ruff `UP006` / `UP035` | references/code_style.md(Functions) | Use built-in generics instead of `typing.Tuple`, `typing.List`, `typing.Dict` | 既存 linter(template-python の ruff `UP006`,`UP035`.template-python は `UP` を選択済み) | なし | なし | 削除(template-python で有効な規則が完全に覆う) | | `py_logging_dict_message`(削除)/ `py_no_structlog_loguru`(新規) | references/code_style.md(Logging) | Write in dictionary format | 辞書形式の規則は削除.標準 `logging` と `extra` を使う方針に変え,structlog と loguru の import を禁止する静的規則(ast-grep,error)を追加 | `py_no_structlog_loguru.yml` | 良 3 / 悪 5 | 辞書形式の文章と例を削除.Logging の節を 3 項目(十分なログ,handler と formatter は entry point だけ,`extra` を出す formatter)に書き直した.ruff `G001`〜`G004`,`G101`,`G201`,`G202`,`LOG002`,`LOG015`,`TRY400` が覆う内容は書かない | | `py_loop_variable_descriptive`(削除) | references/code_style.md(Naming) | Loop body ≥ 3 lines: descriptive name | 規則を削除(名前の良し悪しを形から推測する) | なし | なし | 削除(Iterator arguments の 2 項目とも) | | ruff `N801` / `N802` / `N803` / `N806` / `N999` | references/code_style.md(Naming) | Variables / functions / files: `snake_case`; Classes: `UpperCamelCase` | 既存 linter(template-python の ruff `N`) | なし | なし | 削除(template-python で有効な規則が完全に覆う).「Getters: 出力変数の名前」は残る | | (なし) | references/code_style.md(Naming) | Constants: `SCREAMING_SNAKE_CASE` … module-level constants (two blank lines after imports) | 文章のまま | なし | なし | 残す(ruff `N` は定数の大文字を判定しない.意味のある文字列の定数化は下の `string-literal-is-named-constant` が判定し,文章も残す) | | `string-literal-is-named-constant` | references/code_style.md(Naming) | define semantically meaningful string literals as module-level constants rather than embedding them inline | 動的(jev-lint,0.5) | `model-rules/python/string-literal-is-named-constant/rule.yml` | 延期 | 残して併記(ADR-0021) | | (なし) | references/code_style.md(Naming / Iterator arguments) | Loop body ≤ 2 lines: single character | 文章のまま | なし | なし | 残す(許可であり,違反を構文で定義できない) | | (なし) | references/code_style.md(File Naming) | Name files after the domain/action, not the role suffix; `-er`/`-or` belong on class names | 文章のまま | なし | なし | 残す(語の意味の判断で,ls-lint の正規表現(RE2)で書けない) | | (なし) | references/code_style.md(File Naming) | Avoid `utils.py` / `helpers.py` | 文章のまま | なし | なし | 残す(ls-lint の正規表現(RE2)には否定先読みがなく,template-python の `.ls-lint.yml` では書けない) | | (なし) | references/code_style.md(Functions) | Keep functions focused and small | 文章のまま | なし | なし | 残す(単一責務は `agents/AGENTS.md` の言語非依存の規則が持つ.ruff `C901`,`PLR0912`,`PLR0915` が大きさを一部覆う) | | (なし) | references/code_style.md(Functions) | Use Pythonic syntax (comprehensions, `with` statements, etc.) | 文章のまま | なし | なし | 残す(ruff `C4`,`PERF`,`FURB` が一部を覆うが,全体は判定できない) | | (なし) | references/code_style.md(Formatting) | Let `ruff format` decide quotes and operator spacing | 既存 linter(ruff format)への指示 | なし | なし | 残す(ツールの使い方の指示) | | ruff `I001` / `E301` / `E302` / `E305` | references/code_style.md(Whitespace) | Two blank lines before/after object (class/function) definitions; one blank line between instance methods and between import groups; Imports: standard library → third-party → local with one blank line | 既存 linter(template-python の ruff `I001`,`E30x`) | なし | なし | 削除(template-python で有効な規則が完全に覆う) | | ruff isort `lines-after-imports = 2` | references/code_style.md(Whitespace) | Two blank lines before/after import statements and global variable definitions | 既存 linter(template-python の `lines-after-imports = 2`).グローバル変数は文章のまま | なし | なし | import の行を削除.「グローバル変数の前後 2 行」は ruff に規則がないので残す | | (なし) | references/code_style.md(Whitespace) | One blank line between docstring sections | 文章のまま | なし | なし | 残す(ruff `D2xx` が一部を覆う.`D412` / `D413` は google 規約で無効) | | `import-name-self-explanatory` | references/code_style.md(Imports) | Avoid `from ... import ...` unless the name is self-explanatory; avoid `as` aliases unless required for clarity | 動的(jev-lint,0.5) | `model-rules/python/import-name-self-explanatory/rule.yml` | 延期 | 残して併記(ADR-0021) | | (なし) | references/code_style.md(Indentation) | When handling multiple objects in parallel, align indentation with the previous element | 文章のまま | なし | なし | 残す(`ruff format` が決める書式で,規則の対象外) | | (なし) | references/code_style.md(Line Breaks) | One element per line for lists/dicts with 3+ items or long expressions; trailing comma | 文章のまま(ast-grep は不採用) | なし | なし | 残す(3 要素以上の 1 行リテラルを ast-grep で試すと agent-config で 498 件,中央値 50 文字の短い定数が大半で,誤検出が多すぎた.`ruff format` の magic trailing comma と `E501` が長い式を覆う) | | (なし) | references/code_style.md(Line Breaks) | Don't sacrifice readability for brevity | 文章のまま | なし | なし | 残す(判断の指針) | | (なし) | references/code_style.md(Comments & Docstrings) | Write comments on their own line above the relevant code | 文章のまま | なし | なし | 残す(行末コメントは ast-grep が行の位置を比較できず,ruff にも禁止規則がない) | | ruff `D100` / `D101` / `D102` / `D103` | references/code_style.md(Comments & Docstrings) | Always add docstrings to public APIs | 既存 linter(template-python の ruff `D`,google 規約.`D104` / `D105` / `D107` は template が無効) | なし | なし | 削除(template-python で有効な規則が完全に覆う) | | (なし) | references/code_style.md(Comments & Docstrings) | Comment non-obvious choices (algorithm params, fallback behavior, encoding handling) | 文章のまま | なし | なし | 残す(何が自明でないかは文脈の判断.コメント最小化は `agents/AGENTS.md` が持つ) | | ruff `DOC201` / `DOC402` / `DOC501` / `D417` | references/code_style.md(Comments & Docstrings の例) | Docstring layout (summary, details, `Args`, `Returns/Yields`, `Raises`) | 既存 linter(template-python の `DOC201`,`DOC402`,`DOC501`,`D417`) | なし | なし | 残す(節の並びと空行,例の書式は規則が覆わない.節の有無は linter が判定する) | | `py_definition_order`(削除) | references/models.md(Classes) | prefer `Enum -> model/class -> function` ordering | 規則を削除(従うと `NameError` になる例外を判別できない) | なし | なし | 削除 | | `plain-class-defines-slots`(`py_plain_class_slots` から降格) | references/models.md(Classes) | Use `__slots__` to restrict variables when not using `dataclasses` or `pydantic` | 動的(jev-lint,advisory,0.5).ast-grep 規則はレビューが収束しない(基底,デコレータ,`cached_property` の書き方が多い)ため削除 | `model-rules/python/plain-class-defines-slots/rule.yml` | 延期 | 残して併記(ADR-0021) | | `py_dataclass_slots` | references/models.md(Value Objects) | `dataclasses.dataclass(frozen=True, slots=True)` | 静的(ast-grep,既存) | `py_dataclass_slots.yml`(既存) | 既存 | 変更なし | | `value-object-is-immutable` | references/models.md(Value Objects) | Value Objects: `pydantic.BaseModel` or `dataclass(frozen=True, slots=True)` | 動的(jev-lint,0.5) | `model-rules/python/value-object-is-immutable/rule.yml` | 延期 | 残して併記(ADR-0021).値オブジェクトかどうかは構文から判別できないので,`py_dataclass_slots` の note と合わせてモデルに任せた | | (なし) | references/models.md(Value Objects) | Resolve routine representation choices from existing dependencies and nearby code; ask only when a material decision is not covered | 文章のまま | なし | なし | 残す(進め方の指示) | | (なし) | references/models.md(Value Objects) | Use `__post_init__` to enforce invariants | 文章のまま | なし | なし | 残す(不変条件の有無は構文から判別できない.`agents/AGENTS.md` の Value Object の規則が持つ) | | `construction-placement-by-purity` | references/models.md(Value Objects) | Use classmethods as alternative constructors for pure construction; if construction involves I/O, a module-level function | 動的(jev-lint,0.5) | `model-rules/python/construction-placement-by-purity/rule.yml` | 延期 | 残して併記(ADR-0021) | | `py_pydantic_base_model_only_in_frozen_base` / `py_frozen_base_model_config` / `py_frozen_base_model_no_override` | references/models.md(Pydantic) | Frozen model config: `ConfigDict(extra="forbid", frozen=True, strict=True, validate_default=True)` / shared base class | 静的(ast-grep,error).`BaseModel` を直接継承できるのは `FrozenBaseModel` だけ,その `model_config` は 5 キー(`revalidate_instances="always"` を追加)を持つ,サブクラスは 5 キーを上書きしない | `py_pydantic_base_model_only_in_frozen_base.yml`,`py_frozen_base_model_config.yml`,`py_frozen_base_model_no_override.yml` | 良 5 / 悪 4,良 3 / 悪 3,良 4 / 悪 4 | 削除して書き直し(`FrozenBaseModel` の例と,pydantic は境界だけという 1 行に置換.旧 `py_frozen_config_complete` は削除) | | `json-parse-uses-model-validate-json`(`py_pydantic_validate_json` から降格) | references/models.md(Pydantic) | JSON は `model_validate_json` で読む | 動的(jev-lint,advisory,0.5).データフロー(変数経由,変更の有無)を ast-grep では判定できないため,ast-grep 規則を削除 | `model-rules/python/json-parse-uses-model-validate-json/rule.yml` | 延期 | 文章は残す(pydantic の節の 1 文) | | (なし) | references/models.md(Pydantic) | When multiple frozen models exist, extract a shared base class to `base.py` | 文章のまま | なし | なし | 残す(複数ファイルにまたがる重複の判断で,1 ファイルの構文から判別できない) | | `fixed-choices-use-enum` | references/models.md(Enums) | Use `Enum`/`StrEnum` for fixed choices instead of raw string literals or dict maps | 動的(jev-lint,0.5) | `model-rules/python/fixed-choices-use-enum/rule.yml` | 延期 | 残して併記(ADR-0021) | | (なし) | references/models.md(Enums) | Convert user input strings to Enum early, then map through Enum values | 文章のまま | なし | なし | 残す(境界での変換の位置は `agents/AGENTS.md` の「境界で 1 回だけ型に変換する」規則が持つ) | | ruff `UP042` | references/models.md(Enums) | Prefer `StrEnum` when values are serialized or user-facing | 既存 linter(template-python の `UP042`.`(str, Enum)` の混在を覆う.重複する ast-grep 規則 `py_prefer_strenum` は削除) | なし | なし | 残す(直列化や表示の有無で `Enum` と `StrEnum` を選ぶ判断は規則が覆わない) | | `py_no_unittest` | references/testing.md | Use `pytest` as test framework | 静的(ast-grep,既存) | `py_no_unittest.yml`(既存) | 既存 | 変更なし(「pytest を使う」の指示は残る) | | (なし) | references/testing.md | Run tests using `uv run --frozen pytest` | 文章のまま | なし | なし | 残す(コマンドの指示.`forbidden_commands.json` は一部のバイパスしか覆わない) | | `py_no_pytest_asyncio` | references/testing.md | Use `anyio` for async tests, do not use `asyncio` | 静的(ast-grep) | `py_no_pytest_asyncio.yml`(`pytest.mark.asyncio` と `pytest_asyncio` の import だけを判定.別名の枝は削除) | 良 3 / 悪 4 | 残す(規則は pytest-asyncio の marker と import だけを判定し,`asyncio` 全般は覆わない) | | `py_async_test_anyio_marker`(削除) | references/testing.md(Async test pattern) | `@pytest.mark.anyio` on async tests | 規則を削除.pytest 9.0.3 は,どのプラグインも実行しない async test を失敗にする(使い捨てテストで確認: `async def functions are not natively supported`).黙って成功しないので規則は不要 | なし | なし | 残す(`anyio_backend` fixture の書き方の例) | | `py_no_unittest_mock` | references/testing.md | Use `pytest-mock` for mocking (`mocker` fixture) | 静的(ast-grep,既存) | `py_no_unittest_mock.yml`(既存) | 既存 | 変更なし(「mocker を使う」の指示は残る) | | `py_mocker_patch_autospec` | references/testing.md | (autospec) | 静的(ast-grep,既存) | `py_mocker_patch_autospec.yml`(既存) | 既存 | 変更なし | | (なし) | references/testing.md | `pytest`, `anyio`, and `pytest-mock` belong in the template's test dependency group | 文章のまま | なし | なし | 残す(`pyproject.toml` の内容で,Python の構文ではない.依存の検査は deptry の領域) | | `py_xfail_requires_strict` | references/testing.md | Record a reproduced defect with `@pytest.mark.xfail(strict=True, reason="...")` | 静的(ast-grep,既存) | `py_xfail_requires_strict.yml`(既存) | 既存 | 変更なし | | `known-defect-marker-names-removal` | references/testing.md | …and a comment naming the condition for removing the marker | 動的(jev-lint,既存,0.5) | `model-rules/python/known-defect-marker-names-removal/rule.yml`(既存) | 既存 | 変更なし | | (なし) | references/testing.md | Remove the marker in the change that fixes the defect | 文章のまま | なし | なし | 残す(変更の進め方.差分の文脈が要る) | | (なし) | references/testing.md(Mutation Testing) | Use `mutmut` (3.x) when `tsdd` calls for it; `[tool.mutmut]` config; scope a run; list survivors; keep `mutants/` out of version control | 文章のまま | なし | なし | 残す(ツールの使い方と設定.`.gitignore` と `pyproject.toml` の内容) | | (なし) | references/testing.md(Test Structure) | Function-based by default; class only for namespace grouping or `setup_method`/`teardown_method` | 文章のまま | なし | なし | 残す(namespace のための class を許すので,違反を構文で定義できない) | | `fixture-justified` | references/testing.md(Test Structure) | `@pytest.fixture`: shared setup across 2+ tests, external resources, or teardown; helper function when arguments are needed or setup is light; fixture scope default `function` | 動的(jev-lint,0.5) | `model-rules/python/fixture-justified/rule.yml` | 延期 | 残して併記(ADR-0021) | | `repeated-tests-use-parametrize` | references/testing.md(Test Structure) | `@pytest.mark.parametrize`: same logic with different inputs | 動的(jev-lint,0.5) | `model-rules/python/repeated-tests-use-parametrize/rule.yml` | 延期 | 残して併記(ADR-0021) | | (なし) | references/tooling.md(Package Management) | Use only `uv`, don't use `pip`; `uv sync`; `uv run --frozen {tool}`; `uv add`; `uv add --group`; `uv lock --upgrade-package`; prohibited `uv pip install`, `uv add --dev`, `@latest` | 文章のまま | なし | なし | 残す(シェルコマンドの規則.`agents/hooks/rules/forbidden_commands.json` は `python -m pip` だけを覆う.hook の規則の追加はこの PR の範囲外.ast-grep は Python の構文だけを見る) | | (なし) | references/tooling.md(Package Management) | Baseline tooling dependencies belong in template-defined dependency groups | 文章のまま | なし | なし | 残す(`pyproject.toml` の内容) | | (なし) | references/tooling.md(Directory Structure) | `./src` for production code, `./tests` for tests; flat module placement for apps; `src/<package_name>/` only for distributable packages | 文章のまま | なし | なし | 残す(設計判断.ディレクトリの構成は ls-lint の対象外) | | ruff `E501` | references/tooling.md(File Standards) | Keep code within 119 characters per line (URLs may exceed this limit) | 既存 linter(template-python の ruff `E501`,`line-length = 119`.URL だけの行は除外される) | なし | なし | 削除(template-python で有効な規則が完全に覆う) | | ruff `ANN001` / `ANN002` / `ANN003` / `ANN201` / `ANN202` / `ANN204` | references/tooling.md(File Standards) | Always include type hints | 既存 linter(template-python の ruff `ANN`.`main` の `ignore` に `ANN401` は無い) | なし | なし | 削除(template-python で有効な規則が完全に覆う) | | (なし) | references/tooling.md(File Standards / Static Type Checking) | Use ty for static type checking; run `uv run --frozen ty check`; do not introduce another type checker | 文章のまま | なし | なし | 残す(ツールの選択とコマンド.ty 自体は template の `typecheck` グループが持つ) | | (なし) | SKILL.md(Scope) | Scope: code inside a bootstrapped project; setup belongs to `project-setup`; routine edits do not authorize Nix or GitHub changes | 文章のまま | なし | なし | 残す(skill の適用範囲と権限の境界) | | (なし) | SKILL.md(Task-Specific References) | Read only the references relevant to the current task | 文章のまま | なし | なし | 残す(進め方の指示) | ## 判定に使った設定 - ruff は template-python の `pyproject.toml`(`select` に `ANN`,`D`,`E`,`I`,`N`,`PLW`,`UP` などを含む)を `gh api` で確認した.ruff は dev shell にないため規則 ID はローカルで実行せず,ruff の文書上の規則名で対応させた.template repo は変更していない. - jev-lint の規則は advisory(ADR-0021).Stop の共通 gate は未判定の入力の指摘を 1 回だけ報告して止める(既存の未当てはめ規則と同じ挙動で,hook の変更はこのレーンの範囲外).`threshold: 0.5`,`severity: warning`. ## 波 2: linter で有効化する規則 なし.先に挙げた `lines-after-imports = 2`,`DOC201` / `DOC402` / `DOC501`,`UP042` は template-python(#26)の `main` で有効なことを確認した. ## 現在の hit(修正はこの PR に含めない) ローカル checkout に `ast-grep scan --config agents/hooks/lint/sgconfig.yml .` を読み取りのみで実行した(新しい Python 規則の分). | repo | 規則 | hit | 場所 | | --- | --- | --- | --- | | agent-config | `py_plain_class_slots` | 6 | scripts/replay_commands.py:174,agents/hooks/lib/shell_paths.py:101,agents/hooks/lib/provider_adapter.py:92,tests/skills/test_skill_commands.py:68,tests/hooks/test_trusted_owners_fallback.py:45,tests/hooks/test_static_rules.py:27 | | agent-config | `py_no_nonlocal` | 1 | agents/hooks/lib/check_execution.py:138 | | agent-config | その他の新規則 | 0 | なし | | agent-harness | 新規則すべて | 0 | Python の対象がほぼない | | dotfiles | 新規則すべて | 0 | なし | `py_multiline_collection`(不採用)は同じ方法で agent-config 498 件,dotfiles 89 件の hit があった. ## 検証 - `nix develop --command uv run --frozen pytest tests/test_ast_grep_rules.py tests/test_model_rule_files.py -q`: 55 passed - `nix develop --command ast-grep test --config agents/hooks/lint/sgconfig.yml --skip-snapshot-tests`: 全規則 pass - `jev-lint rules --no-config -R agents/hooks/lint/model-rules/python`: 10 rule(s) loaded, 0 error(s) - jev-lint の dry-run で,7 件の matcher が想定した subject を選ぶことを確認した(モデルの判定は延期) - `ruff check` / `ruff format --check`(tests): pass - 全テスト: `nix develop --command uv run --frozen pytest -q`: 4874 passed, 1 skipped 🤖 Generated with [Claude Code](https://claude.com/claude-code) 追加で,Stop の subject 上限を圧迫しないよう広い jev-lint 規則の matcher(import,文字列,固定選択肢)を絞った(#192 のレビュー対応). ## 後続へ回した指摘(最終方針対応のレビュー上限) 最終方針対応の 3 回目の再レビューが挙げた次の 3 件は修正せず,"Deferred to a follow-up Issue (review limit)." と返信して解決した. - `rules/python/py_async_test_anyio_marker.yml`: 関数名だけで判定し `files:` の制限がないため,本番コードの `async def test_connection(...)` にも error を出す.`files:` をテストファイル(`test_*.py`,`*_test.py`,`conftest.py`)に絞る. - `rules/python/py_async_test_anyio_marker.yml`: `import pytest as pt` の別名を,クラス直下の `pytestmark = pt.mark.anyio` とリスト要素 `pytestmark = [pt.mark.anyio]` にも適用する. - `rules/python/py_frozen_base_model_config.yml`: クラス本体に `model_config` の代入が複数ある場合,最後の代入が完全かどうかを検査する. - 参考(修正しなかったと返信して解決): 間接サブクラスの上書きは単一ファイルの構文では解決できない.`py_no_pytest_asyncio` の別名は,ユーザー決定により `pytest.mark.asyncio` と `pytest_asyncio` の import だけを判定する. ## 後続へ回した指摘(ログ規則追加後のレビュー上限) 次の 4 件は未修正(検出漏れで,誤検出ではない). - `py_pydantic_validate_json`: `data = None; data = json.loads(...)` のように loader 代入より前の初期化があると報告しない(検出漏れ). - `py_pydantic_validate_json`: `json` が標準ライブラリでなく独自オブジェクトのとき(`import json` に結び付けていない)も報告する. - `py_async_test_anyio_marker`: `anyio_backend` を別の fixture(`client` や autouse)経由で使う async test は,fixture の依存関係を単一ファイルの構文では解決できないため,まだ未マークとして報告する. - `py_frozen_base_model_no_override`: `ConfigDict(**{"frozen": False})` のように展開した辞書を `bad_pair` で検査しない. ## 誤検出の修正(ユーザー許可,10ba684) blocking にする前の誤検出として,次の 3 件を failing な valid 例を先に足してから直した. - [x] `py_pydantic_validate_json`(決定変更): loader に追加引数があっても報告し続ける.同じ関数で `$D = json.loads(...)`(別名,`from json import loads [as x]`,orjson,ujson を含む)として代入した変数を `model_validate($D)` に渡す形も報告する(ast-grep が関係をまたいで `$D` を束ねることをテストで確認).`json.loads` だけで `model_validate` に渡さない場合は報告しない. - [x] `py_plain_class_slots` / `py_dataclass_slots`: `cached_property` の別名の除外が,デコレータ付きクラスとネストしたクラスでも効く. - [x] `py_async_test_anyio_marker`: `from pytest import mark` がある場合の bare `@mark.usefixtures("anyio_backend")` / `@mark.anyio`,`pytestmark = [pytest.mark.usefixtures("anyio_backend"), ...]` と `[pytest.mark.anyio, ...]` のリスト形式を受け入れる. ## blocking の message と note ブロックする全規則に,なぜ誤りか(`message`)と,そのまま適用できる直し方(`note`,before/after)を書いた. `py_async_test_anyio_marker` は `files:`(`test_*.py`,`*_test.py`,`conftest.py`)に限定した. ## main 取り込み後の対応 - `test` が失敗した原因: main の #202 が「`files:` で絞った規則はすべて flagged / clean のパスを持つ」テストを足し,`py_async_test_anyio_marker` が対象になった.main を取り込み,`tests/test_ast_grep_rules.py` にこの規則のパスを追加した(全テスト 4921 passed). - `py_pydantic_validate_json`(誤検出,修正済み): loader 代入を探す関数を呼び出しに最も近い関数に限った.外側で `data = json.loads(...)`,内側の関数が別の `data` 引数を検証する形を報告しない(valid 例を追加). - 後続へ回した指摘(未修正,検出漏れ): `py_plain_class_slots` は `__slots__ = ("__dict__",)` を有効扱いする.#196 のコメントに追記した. - 後続へ回した指摘(未修正): `py_pydantic_base_model_only_in_frozen_base` は `pydantic.v1.BaseModel` を検出しない(検出漏れ).`fixture-justified` は基準の文言が衝突している(advisory).どちらも #196 のコメントに追記した. - 誤検出の修正(8bb159c): `py_async_test_anyio_marker` は,別名 `pytest` の `usefixtures('anyio_backend')`(単引用符)も受け入れる.`conftest.py` は対象から外し,`py_pydantic_validate_json` は loader 代入が検証より前にある場合だけ一致する(f8207ea). - 後続へ回した指摘(未修正,検出漏れ): `py_pydantic_validate_json` は複数名 import(`from json import dumps, loads as x`)の別名を追跡しない.#196 のコメントに追記した. - 誤検出の修正(b402713,d5931b5): 別名 `pytest` の `pytestmark`(`usefixtures("anyio_backend")`,クラス直下の `mark.anyio`)も受け入れる. - 後続へ回した指摘(未修正,検出漏れ): 別名の分岐は receiver を厳密に別名へ結び付けていない.#196 のコメントに追記した. - 誤検出の修正(0ea63c6): 別名 `pytest` のモジュール直下 `pytestmark` リスト,`from functools import lru_cache, cached_property as x` の複数名 import(`py_dataclass_slots` と `py_plain_class_slots`)を受け入れる. - 誤検出の修正(04fc613): `py_pydantic_validate_json` は,無条件の先行代入だけを loader 代入として扱う(`if` の中の代入は対象外).note には `strict=False` などの呼び出しオプションを保つ直し方も書いた(7cf166b). - 後続へ回した指摘(未修正,検出漏れ): `py_plain_class_slots` は `class User():` と `class User(object):` を継承ありとして除外する.#196 のコメントに追記した. - 誤検出の修正(2ba6e0b): `py_frozen_base_model_config` は,5 設定がクラスのキーワードと `model_config` に分かれていても合わせて判定する.`py_async_test_anyio_marker` は `from pytest import mark as x` の別名も受け入れる. - 誤検出の修正(bccac41): `py_pydantic_validate_json` は `from json import loads as x` を素の `loads` とみなさない. - 後続へ回した指摘(未修正): `anyio_mode = "auto"` のプロジェクトでは `py_async_test_anyio_marker` が誤検出になる.pytest 設定を単一ファイルの規則から読めないため規則内では直せない.#196 のコメントに追記した. ## 不安定な規則の整理(上の履歴より新しい) レビューが収束しなかった次の ast-grep 規則を削除した.上のレビュー対応の記述のうち,これらの規則に関するものは古い. - `py_async_test_anyio_marker`: 削除.pytest 9.0.3 では,マーカーなしの async test は失敗する(`pytest==9.0.3` と `anyio` で使い捨てテストを実行して確認). - `py_pydantic_validate_json` → jev-lint `json-parse-uses-model-validate-json`,`py_plain_class_slots` → jev-lint `plain-class-defines-slots`(advisory,`threshold: 0.5`,当てはめは延期).規則テストと,これらの規則に関する #196 の後続項目は不要になった. - 全テスト: 4913 passed, 1 skipped. ## ast-grep から外した規則と理由 ブロックする規則は安定していなければならない.次の規則はレビューのたびに新しい指摘が出て収束しなかったため,既存のツールに任せるか jev-lint へ降格することをユーザーが決めた.判断の基準は ADR-0021 に記録する. | 規則 | 行き先 | review の指摘数 | 不安定の型 | 例 | | --- | --- | --- | --- | --- | | `py_async_test_anyio_marker` | 削除.pytest 9.0.3 が,どのプラグインも実行しない async test を失敗にする(使い捨てテストで確認) | 34 | 1) ファイルの外の情報が要る(`anyio_mode = "auto"` は pytest 設定,`anyio_backend` の使用は fixture の依存関係や `conftest.py`)<br>4) 同じ意味の書き方が多い(`pytestmark` のリストとクラス直下,別名 import,単引用符,`usefixtures` の引数位置) | 誤検出: `@pt.mark.usefixtures('anyio_backend')`,`from pytest import mark as m`,`class Helper:` 内の `async def test_x`.検出漏れ: `anyio_backend` を別の fixture 経由で使う | | `py_pydantic_validate_json` | jev-lint `json-parse-uses-model-validate-json` | 17 | 2) データの流れや実行の順番を追う必要がある(変数に代入してから検証,代入の前後,条件付き代入,検証前の変更)<br>4) 同じ意味の書き方が多い(`json.loads`,別名 import,複数名 import,`orjson`,`ujson`) | 誤検出: `data["id"] = request_id` の後の `Order.model_validate(data)`.検出漏れ: `from json import dumps, loads as decode_json` の `decode_json(raw)` | | `py_plain_class_slots` | jev-lint `plain-class-defines-slots` | 11 | 4) 同じ意味の書き方が多い(基底クラス,デコレータ,`cached_property` の別名,`class User():`)<br>2) データの流れや実行の順番を追う必要がある(`__init__` の代入先) | 誤検出: `from functools import lru_cache, cached_property as cached` を使うクラス.検出漏れ: `__slots__ = ("__dict__",)`,`class User(object):` | | `py_frozen_base_model_no_override` | jev-lint `frozen-model-subclass-keeps-locked-settings` | 4 | 2) データの流れや実行の順番を追う必要がある(クラスの継承を複数のクラスやファイルにまたがって追う)<br>4) 同じ意味の書き方が多い(クラスキーワード,`model_config` の `ConfigDict` と辞書) | 検出漏れ: `class Money(FrozenBaseModel)` の後の `class MutableMoney(Money, strict=False)`.誤検出: 5 設定がクラスキーワードと `model_config` に分かれた定義 | | `py_frozen_base_model_config` | jev-lint `frozen-base-model-sets-all-settings` | 8 | 2) データの流れや実行の順番を追う必要がある(名前付きの設定定数,`model_config` の再代入)<br>4) 同じ意味の書き方が多い(クラスキーワード,`ConfigDict` と辞書,分割した定義) | 誤検出: `model_config = COMPLETE_CONFIG`(定数に 5 設定が入っている).検出漏れ: `model_config` を再代入して設定を失う | 指摘数は,この PR のレビュースレッドのうち,規則ファイルのパスに付いたものの数. `json-parse-uses-model-validate-json` の基準は,`object_hook` や `parse_float` などの変換オプション付きの `json.loads` を `model_validate_json` と同等とみなさない. --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
agent-config の hook を Python 3.15.1 で動かす.nixpkgs にはまだ 3.15.1 がないので,dotfiles とは独立に自前でビルドする.
Refs #23
計画: #23 (comment)
追加(
UV_LOCKED): #23 (comment)変更
nix/python.nix: Python 3.15.1 のビルド(mimetypes のパッチを外しpostPatchで置換).nixpkgs に 3.15.1 が入ったら削除する TODO 付きnix/uv.nix: uv 0.13.5 の公式バイナリ(4 プラットフォーム,Linux は musl 静的版)flake.nix: hook の shebang と devShell がこの 2 つを使うpyproject.toml:requires-python = ">= 3.15.1, < 3.16",ruffpy315,.python-versionは3.15,uv.lock再生成scripts/bootstrap_server.sh:PYTHON_VERSIONの既定値 3.15.1,uv installer を 0.13.5 に固定し,それより古い uv は停止UV_LOCKED=1(--frozenを外す),setup-uvに uv 0.13.5 と Python 3.15.1 を指定,Python をソースからビルドするジョブの timeout を 20 分に延長確認
nix build .#default,nix flake check,pytest 2700 件,ruff,ty,deptry,vulture,bats 47 件,shellcheck,shfmtb0887f1): 全ジョブ成功.x86_64-linux のnix-check4m35s,bootstrap10sレビュー(1 回目)
P0 なし.P1: 自前 CPython のソースビルドで bats と shell-lint が timeout 10 分中 8 分かかる → timeout を 20 分に延長(修正済み).
修正済みの P2: コメントに残った 3.14 の記述,uv のバージョン接尾辞(
+local,-rc)で止まりうる比較,bats ヘルパーがUV_VERSIONとPYTHON_VERSIONを漏らす,偽インタプリタ名.未対応の P2:
nix/python.nixのpostPatchはknownfilesの先頭 1 行だけを mailcap に置換するため,/etc/httpd/mime.typesなどホストのパスが 8 件残る(元の nixpkgs パッチは mailcap 1 件だけにしていた).dotfiles のpython_315.nixと同じ方法で,影響は小さいoverrideAttrsは passthru を作り直さないため,.pkgsと.withPackagesは 3.15.0 のまま.現在は使っていない範囲外
exclude-newer = "1 week").この PR は Issue を閉じない🤖 Generated with Claude Code