From 3c42e639db9780eca41e362a8601cfd64c9dcc1d Mon Sep 17 00:00:00 2001 From: Junhyuk Lee Date: Wed, 29 Apr 2026 15:20:36 +0000 Subject: [PATCH] Advance OSS contribution for openai migration on Windows WSL error. instructions are wrong Nightly Codex produced a focused contribution for https://github.com/openai/openai-python/issues/1880. Constraint: Automated nightly run; keep changes small and reviewable. Confidence: medium Scope-risk: narrow Tested: See uploaded nightly artifacts and workflow logs. Not-tested: Maintainer CI beyond this workflow. --- NIGHTLY_CODEX_FINAL_ATTEMPT_1.md | 12 ++++++++++++ src/openai/cli/_tools/migrate.py | 6 +++++- tests/cli/test_tools_migrate.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 NIGHTLY_CODEX_FINAL_ATTEMPT_1.md create mode 100644 tests/cli/test_tools_migrate.py diff --git a/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md new file mode 100644 index 0000000000..175acc840b --- /dev/null +++ b/NIGHTLY_CODEX_FINAL_ATTEMPT_1.md @@ -0,0 +1,12 @@ +Implemented a small targeted fix for [issue #1880](https://github.com/openai/openai-python/issues/1880). + +Changed [src/openai/cli/_tools/migrate.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/src/openai/cli/_tools/migrate.py:85) so the Windows migration CLI error now points users to WSL and clarifies that `openai migrate` downloads and invokes Grit directly, without `grit install` or PATH edits. + +Added focused tests in [tests/cli/test_tools_migrate.py](/home/runner/work/oss-nightly-control/oss-nightly-control/target/tests/cli/test_tools_migrate.py:1), and wrote [NIGHTLY_REPORT.md](/home/runner/work/oss-nightly-control/oss-nightly-control/target/NIGHTLY_REPORT.md:1). + +Verification passed: +- `pytest ... tests/cli/test_tools_migrate.py -q` → `2 passed` +- `ruff format --check ...` → passed +- `ruff check ...` → passed + +I did not commit, push, or open a PR. Note: `.codex-nightly-prompt.md` and `uv.lock` were already untracked when I started; I left them alone. \ No newline at end of file diff --git a/src/openai/cli/_tools/migrate.py b/src/openai/cli/_tools/migrate.py index 841b777528..a53be63e09 100644 --- a/src/openai/cli/_tools/migrate.py +++ b/src/openai/cli/_tools/migrate.py @@ -82,7 +82,11 @@ def _debug(message: str) -> None: def install() -> Path: """Installs the Grit CLI and returns the location of the binary""" if sys.platform == "win32": - raise CLIError("Windows is not supported yet in the migration CLI") + raise CLIError( + "Windows is not supported directly in the migration CLI. To migrate on Windows, " + "run `openai migrate` from WSL or another Linux/macOS shell; the command downloads " + "and invokes Grit itself, so you do not need to install `grit` or add it to PATH." + ) _debug("Using Grit installer from GitHub") diff --git a/tests/cli/test_tools_migrate.py b/tests/cli/test_tools_migrate.py new file mode 100644 index 0000000000..5f0c78ecd5 --- /dev/null +++ b/tests/cli/test_tools_migrate.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from pathlib import Path + +import pytest + +from openai.cli._tools import migrate +from openai.cli._errors import CLIError + + +def test_install_explains_how_to_migrate_on_windows(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(migrate.sys, "platform", "win32") + + with pytest.raises(CLIError) as exc_info: + migrate.install() + + message = str(exc_info.value) + assert "run `openai migrate` from WSL" in message + assert "do not need to install `grit` or add it to PATH" in message + + +def test_migrate_invokes_downloaded_grit_without_requiring_path(monkeypatch: pytest.MonkeyPatch) -> None: + calls: list[list[str | Path]] = [] + + monkeypatch.setattr(migrate, "install", lambda: Path("/tmp/grit")) + monkeypatch.setattr(migrate.subprocess, "check_call", calls.append) + + migrate.migrate(migrate.MigrateArgs(unknown_args=["--force"])) + + assert calls == [[Path("/tmp/grit"), "apply", "openai", "--force"]]