fix: resolve lint issues in Windows CLI subprocess fix

- Fix RUF005: Use spread syntax instead of concatenation in install_crew.py
- Fix S108: Replace /tmp with /home/test in test paths
- Fix E501: Shorten function name to meet line length requirements

These changes address the lint failures in CI while maintaining the core
Windows subprocess compatibility fix.

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-09-16 17:53:05 +00:00
parent 9e04b65549
commit 44ba420130
2 changed files with 10 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ def install_crew(proxy_options: list[str]) -> None:
Install the crew by running the UV command to lock and install.
"""
try:
command = ["uv", "sync"] + proxy_options
command = ["uv", "sync", *proxy_options]
run_command(command, check=True, capture_output=False, text=True)
except subprocess.CalledProcessError as e:

View File

@@ -1,4 +1,3 @@
import platform
import subprocess
from unittest import mock
@@ -24,7 +23,7 @@ class TestRunCommand:
mock_subprocess_run.assert_called_once()
call_args = mock_subprocess_run.call_args
assert call_args[1]["shell"] is True
assert isinstance(call_args[0][0], str)
assert "uv run test" in call_args[0][0]
@@ -43,7 +42,7 @@ class TestRunCommand:
mock_subprocess_run.assert_called_once()
call_args = mock_subprocess_run.call_args
assert call_args[1].get("shell", False) is False
assert call_args[0][0] == command
@@ -62,7 +61,7 @@ class TestRunCommand:
mock_subprocess_run.assert_called_once()
call_args = mock_subprocess_run.call_args
command_str = call_args[0][0]
assert '"hello world"' in command_str or "'hello world'" in command_str
@mock.patch("platform.system")
@@ -89,18 +88,18 @@ class TestRunCommand:
capture_output=True,
text=False,
check=False,
cwd="/tmp",
cwd="/home/test",
env={"TEST": "value"},
timeout=30
)
mock_subprocess_run.assert_called_once()
call_args = mock_subprocess_run.call_args
assert call_args[1]["capture_output"] is True
assert call_args[1]["text"] is False
assert call_args[1]["check"] is False
assert call_args[1]["cwd"] == "/tmp"
assert call_args[1]["cwd"] == "/home/test"
assert call_args[1]["env"] == {"TEST": "value"}
assert call_args[1]["timeout"] == 30
@@ -118,13 +117,13 @@ class TestRunCommand:
mock_subprocess_run.assert_called_once()
call_args = mock_subprocess_run.call_args
assert call_args[1].get("shell", False) is False
assert call_args[0][0] == command
@mock.patch("platform.system")
@mock.patch("subprocess.run")
def test_windows_string_command_passthrough(self, mock_subprocess_run, mock_platform):
def test_windows_string_passthrough(self, mock_subprocess_run, mock_platform):
"""Test that Windows passes through string commands unchanged."""
mock_platform.return_value = "Windows"
mock_subprocess_run.return_value = subprocess.CompletedProcess(
@@ -136,6 +135,6 @@ class TestRunCommand:
mock_subprocess_run.assert_called_once()
call_args = mock_subprocess_run.call_args
assert call_args[0][0] == command_str
assert call_args[1]["shell"] is True