Check root Python script formatting in CI (#25165)

## Why

Python files under `scripts/` were not covered by the repository
formatting recipe or the CI formatting job, so formatting drift could
merge unnoticed.

## What

- Add a dedicated `scripts/pyproject.toml` and `scripts/uv.lock` so
root-script formatting uses a locked Ruff version.
- Extend `just fmt` to format root Python scripts and add
`fmt-scripts-check` for CI.
- Run `just fmt-scripts-check` from `.github/workflows/ci.yml`,
installing `uv` through SHA-pinned `astral-sh/setup-uv` while retaining
the `uv` `0.11.3` pin.
- Apply Ruff formatting to the root Python scripts, including
`scripts/just-shell.py`, and extend
`sdk/python/tests/test_artifact_workflow_and_binaries.py` to cover the
root formatting recipe.
- Update `AGENTS.md` so agents run `just fmt` after code changes
anywhere in the repository.

## Validation

- Extended the existing Python SDK workflow test to assert that `just
fmt` includes root Python scripts.
This commit is contained in:
Adam Perry @ OpenAI
2026-06-01 11:50:23 -07:00
committed by GitHub
Unverified
parent c3cdf3c007
commit 281b416c44
17 changed files with 183 additions and 52 deletions
@@ -68,8 +68,8 @@ def test_generation_has_single_maintenance_entrypoint_script() -> None:
assert scripts == ["update_sdk_artifacts.py"]
def test_root_fmt_recipe_formats_rust_and_python_sdk() -> None:
"""The repo fmt command should work from Rust and Python SDK directories."""
def test_root_fmt_recipe_formats_rust_python_sdk_and_scripts() -> None:
"""The repo fmt command should format Rust, the Python SDK, and scripts."""
justfile = ROOT.parents[1] / "justfile"
lines = justfile.read_text().splitlines()
fmt_index = lines.index("fmt:")
@@ -88,16 +88,18 @@ def test_root_fmt_recipe_formats_rust_and_python_sdk() -> None:
}
expected = {
"working_directory": 'set working-directory := "codex-rs"',
"previous_comment": "# Format Rust and Python SDK code.",
"previous_comment": "# Format Rust, Python SDK code, and Python scripts.",
"commands": [
"cargo fmt -- --config imports_granularity=Item {stderr-null}",
"uv run --frozen --project ../sdk/python --extra dev ruff check --fix --fix-only ../sdk/python",
"uv run --frozen --project ../sdk/python --extra dev ruff format ../sdk/python",
"# Root scripts have their own locked Ruff environment.",
"uv run --frozen --project ../scripts ruff format ../scripts",
],
}
assert actual == expected, (
"The root `just fmt` recipe must run Rust fmt and Python SDK Ruff. "
"The root `just fmt` recipe must run Rust fmt and Ruff for Python SDK code and scripts. "
"Fix the `fmt` recipe in `justfile`, then run `just fmt`.\n"
f"Expected: {json.dumps(expected, indent=2)}\n"
f"Actual: {json.dumps(actual, indent=2)}"