mirror of
https://github.com/openai/codex.git
synced 2026-04-25 23:24:55 +00:00
## 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`
36 lines
784 B
Python
Executable File
36 lines
784 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
|
|
from wrapper_common import (
|
|
build_final_args,
|
|
ensure_source_prerequisites,
|
|
exec_command,
|
|
parse_wrapper_args,
|
|
repo_root,
|
|
set_default_lint_env,
|
|
)
|
|
|
|
|
|
def main() -> "Never":
|
|
root = repo_root()
|
|
parsed = parse_wrapper_args(sys.argv[1:])
|
|
final_args = build_final_args(parsed, root / "codex-rs" / "Cargo.toml")
|
|
|
|
env = os.environ.copy()
|
|
ensure_source_prerequisites(env)
|
|
set_default_lint_env(env)
|
|
|
|
command = ["cargo", "dylint", "--path", str(root / "tools" / "argument-comment-lint")]
|
|
if not parsed.has_library_selection:
|
|
command.append("--all")
|
|
command.extend(final_args)
|
|
exec_command(command, env)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|