Skip to content

refactor: rewrite argument-comment lint wrappers in Python#16063

Merged
bolinfest merged 1 commit intomainfrom
pr16063
Mar 28, 2026
Merged

refactor: rewrite argument-comment lint wrappers in Python#16063
bolinfest merged 1 commit intomainfrom
pr16063

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Mar 28, 2026

Why

The argument-comment-lint entrypoints had grown into two shell wrappers with duplicated parsing, environment setup, and Cargo forwarding logic. The recent -- separator regression was a good example of the problem: the behavior was subtle, easy to break, and hard to verify.

This change rewrites those wrappers in Python so the control flow is easier to follow, the shared behavior lives in one place, and the tricky argument/defaulting paths have direct test coverage.

What changed

  • replaced tools/argument-comment-lint/run.sh and tools/argument-comment-lint/run-prebuilt-linter.sh with Python entrypoints: run.py and run-prebuilt-linter.py
  • moved shared wrapper behavior into tools/argument-comment-lint/wrapper_common.py, including:
    • splitting lint args from forwarded Cargo args after --
    • defaulting repo runs to --manifest-path codex-rs/Cargo.toml --workspace --no-deps
    • defaulting non---fix runs to --all-targets unless the caller explicitly narrows the target set
    • setting repo defaults for DYLINT_RUSTFLAGS and CARGO_INCREMENTAL
  • kept the prebuilt wrapper thin: it still just resolves the packaged DotSlash entrypoint, keeps rustup shims first on PATH, infers RUSTUP_HOME when needed, and then launches the packaged cargo-dylint path
  • updated justfile, rust-ci.yml, and tools/argument-comment-lint/README.md to use the Python entrypoints
  • updated rust-ci so the package job runs Python syntax checks plus the new wrapper unit tests, and the OS-specific lint jobs invoke the wrappers through an explicit Python interpreter

This is a follow-up to #16054: it keeps the current lint semantics while making the wrapper logic maintainable enough to iterate on safely.

Validation

  • python3 -m py_compile tools/argument-comment-lint/wrapper_common.py tools/argument-comment-lint/run.py tools/argument-comment-lint/run-prebuilt-linter.py tools/argument-comment-lint/test_wrapper_common.py
  • python3 -m unittest discover -s tools/argument-comment-lint -p 'test_*.py'
  • python3 ./tools/argument-comment-lint/run-prebuilt-linter.py -p codex-terminal-detection -- --lib
  • python3 ./tools/argument-comment-lint/run.py -p codex-terminal-detection -- --lib
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d849d5e545

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if: ${{ runner.os != 'macOS' }}
shell: bash
run: ./tools/argument-comment-lint/run-prebuilt-linter.sh -- --lib --bins
run: ./tools/argument-comment-lint/run-prebuilt-linter.py -- --lib --bins
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Pin Python runtime before running lint wrapper

This step now executes run-prebuilt-linter.py directly, which depends on python3 via the shebang, but the job does not install or pin a Python runtime. Because this matrix includes self-hosted Windows runners (runner.os != 'macOS'), any runner image without a python3 shim will fail before linting starts; the previous .sh wrapper did not introduce that dependency. Please add an explicit Python setup (or invoke a guaranteed interpreter) in this job.

Useful? React with 👍 / 👎.

@bolinfest bolinfest merged commit 5037a2d into main Mar 28, 2026
37 checks passed
@bolinfest bolinfest deleted the pr16063 branch March 28, 2026 02:42
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

1 participant