Skip to content

Commit 8871443

Browse files
claudemldangelo
andcommitted
fix: add type annotations and clean up CI workarounds
- Add proper type annotation for cmd variable (Union[str, list[str]]) - Run ruff format to fix formatting issues - Remove retry logic from CI workflow (no longer needed) - Remove npm cache cleanup (no longer needed) The core Windows fix (shell=True for .cmd execution) resolves the root cause, making the retry and cache cleanup workarounds unnecessary. Co-Authored-By: Michael D'Angelo <michael@promptfoo.dev> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent afb5961 commit 8871443

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,8 @@ jobs:
8686
- name: Install package
8787
run: uv sync
8888

89-
- name: Clear npm cache on Windows
90-
if: runner.os == 'Windows'
91-
run: npm cache clean --force
92-
continue-on-error: true
93-
9489
- name: Test CLI can be invoked
95-
uses: nick-fields/retry@v3
96-
with:
97-
timeout_minutes: 3
98-
max_attempts: 3
99-
retry_on: error
100-
command: uv run promptfoo --version
90+
run: uv run promptfoo --version
10191

10292
- name: Test Node.js detection
10393
run: uv run python -c "from promptfoo.cli import check_node_installed, check_npx_installed; assert check_node_installed(); assert check_npx_installed()"

src/promptfoo/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import shutil
1111
import subprocess
1212
import sys
13-
from typing import NoReturn
13+
from typing import NoReturn, Union
1414

1515

1616
def check_node_installed() -> bool:
@@ -58,10 +58,12 @@ def main() -> NoReturn:
5858
is_windows = platform.system() == "Windows"
5959

6060
# On Windows, we need special handling for .cmd files
61+
cmd: Union[str, list[str]]
6162
if is_windows:
6263
# On Windows, build command as string for shell=True
6364
# This properly handles npx.cmd batch file execution
6465
import shlex
66+
6567
args = ["npx", "--yes", "promptfoo@latest"] + sys.argv[1:]
6668
cmd = " ".join(shlex.quote(arg) for arg in args)
6769
use_shell = True

0 commit comments

Comments
 (0)