Skip to content

Commit 0b39331

Browse files
committed
chore(Makefile): update all target to include formatcheck for better code quality
style(shell_executor.py): format code for consistency and readability style(test_shell_executor.py): format test cases for improved readability and consistency
1 parent b8ff88c commit 0b39331

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ coverage:
2525
# Run all checks required before pushing
2626
check: lint typecheck test
2727
fix: check format
28-
all: check test coverage
28+
all: formatcheck test coverage

src/mcp_shell_server/shell_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _validate_pipeline(self, commands: List[str]) -> None:
269269
raise ValueError("Empty command before pipe operator")
270270
self._validate_command(current_cmd)
271271
current_cmd = []
272-
elif token in [";" , "&&", "||"]:
272+
elif token in [";", "&&", "||"]:
273273
raise ValueError(f"Unexpected shell operator in pipeline: {token}")
274274
else:
275275
current_cmd.append(token)

tests/test_shell_executor.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,19 @@ def test_create_shell_command(executor):
429429
"""Test shell command creation with various input combinations"""
430430
# Test basic command
431431
assert executor._create_shell_command(["echo", "hello"]) == "echo hello"
432-
432+
433433
# Test command with space-only argument
434434
assert executor._create_shell_command(["echo", " "]) == "echo ' '"
435-
435+
436436
# Test command with wildcards
437437
assert executor._create_shell_command(["ls", "*.txt"]) == "ls '*.txt'"
438-
438+
439439
# Test command with special characters
440-
assert executor._create_shell_command(["echo", "hello;", "world"]) == "echo 'hello;' world"
441-
440+
assert (
441+
executor._create_shell_command(["echo", "hello;", "world"])
442+
== "echo 'hello;' world"
443+
)
444+
442445
# Test empty command
443446
assert executor._create_shell_command([]) == ""
444447

@@ -447,31 +450,31 @@ def test_preprocess_command(executor):
447450
"""Test command preprocessing for pipeline handling"""
448451
# Test basic command
449452
assert executor._preprocess_command(["ls"]) == ["ls"]
450-
453+
451454
# Test command with separate pipe
452455
assert executor._preprocess_command(["ls", "|", "grep", "test"]) == [
453456
"ls",
454457
"|",
455458
"grep",
456459
"test",
457460
]
458-
461+
459462
# Test command with attached pipe
460463
assert executor._preprocess_command(["ls|", "grep", "test"]) == [
461464
"ls",
462465
"|",
463466
"grep",
464467
"test",
465468
]
466-
469+
467470
# Test command with special operators
468471
assert executor._preprocess_command(["echo", "hello", "&&", "ls"]) == [
469472
"echo",
470473
"hello",
471474
"&&",
472475
"ls",
473476
]
474-
477+
475478
# Test empty command
476479
assert executor._preprocess_command([]) == []
477480

0 commit comments

Comments
 (0)