style: apply ruff format to PR files
Fix ruff format check failures on files introduced by this PR: - features/steps/cli_error_handling_steps.py - features/steps/sandbox_manager_concurrency_steps.py - src/cleveragents/cli/output/_cli_output_manager.py - src/cleveragents/cli/output.py
This commit is contained in:
@@ -163,14 +163,14 @@ def step_display_error_panel(context: Any, title: str, content: str) -> None:
|
||||
sys.stderr = old_stderr
|
||||
|
||||
|
||||
@then('a green panel should be displayed')
|
||||
@then("a green panel should be displayed")
|
||||
def step_check_green_panel(context: Any) -> None:
|
||||
"""Check that a green panel is displayed."""
|
||||
output = context.stdout_capture.getvalue()
|
||||
assert "green" in output or "┌" in output or "│" in output
|
||||
|
||||
|
||||
@then('a red panel should be displayed')
|
||||
@then("a red panel should be displayed")
|
||||
def step_check_red_panel(context: Any) -> None:
|
||||
"""Check that a red panel is displayed."""
|
||||
output = context.stderr_capture.getvalue()
|
||||
@@ -187,9 +187,7 @@ def step_check_panel_title(context: Any, title: str) -> None:
|
||||
@when('I display a table with columns "{columns}"')
|
||||
def step_display_table_columns(context: Any, columns: str) -> None:
|
||||
"""Set up table columns."""
|
||||
context.table_columns = [
|
||||
(col.strip(), None) for col in columns.split(",")
|
||||
]
|
||||
context.table_columns = [(col.strip(), None) for col in columns.split(",")]
|
||||
|
||||
|
||||
@when("the table contains {row_count:d} rows of data")
|
||||
@@ -237,6 +235,7 @@ def step_check_json_output(context: Any) -> None:
|
||||
def step_check_valid_json(context: Any) -> None:
|
||||
"""Check that the output is valid JSON."""
|
||||
import json
|
||||
|
||||
output = context.stdout_capture.getvalue()
|
||||
try:
|
||||
json.loads(output)
|
||||
|
||||
@@ -137,16 +137,20 @@ def step_when_commit_all_runs_concurrently(
|
||||
|
||||
assert harness.commit_finished.is_set(), "commit_all did not finish in test window"
|
||||
assert harness.creation_done.is_set(), "sandbox creation thread did not finish"
|
||||
assert context.commit_error is None, f"Unexpected commit error: {context.commit_error}"
|
||||
assert context.commit_error is None, (
|
||||
f"Unexpected commit error: {context.commit_error}"
|
||||
)
|
||||
|
||||
|
||||
@then("the concurrent sandbox creation should wait for commit completion")
|
||||
def step_then_creation_waited(context: Any) -> None:
|
||||
harness: _ConcurrencyHarness = context.concurrency_harness
|
||||
assert (
|
||||
harness.creation_completed_before_release is False
|
||||
), "Sandbox creation should have been blocked until commit finished"
|
||||
assert harness.creation_error is None, f"Sandbox creation failed: {harness.creation_error}"
|
||||
assert harness.creation_completed_before_release is False, (
|
||||
"Sandbox creation should have been blocked until commit finished"
|
||||
)
|
||||
assert harness.creation_error is None, (
|
||||
f"Sandbox creation failed: {harness.creation_error}"
|
||||
)
|
||||
assert context.created_sandbox is not None, "Sandbox creation never completed"
|
||||
|
||||
|
||||
|
||||
@@ -269,9 +269,7 @@ def handle_cli_error(
|
||||
except CleverAgentsError as exc:
|
||||
manager = CLIOutputManager(
|
||||
debug=kwargs.get("debug", False),
|
||||
output_format=kwargs.get(
|
||||
"output_format", OutputFormat.RICH.value
|
||||
),
|
||||
output_format=kwargs.get("output_format", OutputFormat.RICH.value),
|
||||
)
|
||||
manager.handle_exception(
|
||||
exc,
|
||||
@@ -283,9 +281,7 @@ def handle_cli_error(
|
||||
except Exception as exc:
|
||||
manager = CLIOutputManager(
|
||||
debug=kwargs.get("debug", False),
|
||||
output_format=kwargs.get(
|
||||
"output_format", OutputFormat.RICH.value
|
||||
),
|
||||
output_format=kwargs.get("output_format", OutputFormat.RICH.value),
|
||||
)
|
||||
manager.handle_exception(
|
||||
exc,
|
||||
|
||||
@@ -29,6 +29,7 @@ def display_success(
|
||||
"""Display a success message to stdout."""
|
||||
if output_format in ("json", "yaml"):
|
||||
import json as _json
|
||||
|
||||
print(_json.dumps({"status": "success", "message": message}), file=sys.stdout)
|
||||
elif output_format == "plain":
|
||||
print(f"✓ {message}", file=sys.stdout)
|
||||
@@ -44,6 +45,7 @@ def display_warning(
|
||||
"""Display a warning message to stdout."""
|
||||
if output_format in ("json", "yaml"):
|
||||
import json as _json
|
||||
|
||||
print(_json.dumps({"status": "warning", "message": message}), file=sys.stdout)
|
||||
elif output_format == "plain":
|
||||
print(f"⚠ {message}", file=sys.stdout)
|
||||
@@ -59,6 +61,7 @@ def display_info(
|
||||
"""Display an informational message to stdout."""
|
||||
if output_format in ("json", "yaml"):
|
||||
import json as _json
|
||||
|
||||
print(_json.dumps({"status": "info", "message": message}), file=sys.stdout)
|
||||
elif output_format == "plain":
|
||||
print(f"i {message}", file=sys.stdout)
|
||||
@@ -75,6 +78,7 @@ def display_error_panel(
|
||||
"""Display an error panel to stderr."""
|
||||
if output_format in ("json", "yaml"):
|
||||
import json as _json
|
||||
|
||||
data = {"status": "error", "title": title, "content": content}
|
||||
print(_json.dumps(data), file=sys.stderr)
|
||||
elif output_format == "plain":
|
||||
@@ -90,7 +94,6 @@ def display_error_panel(
|
||||
print(chr(10).join(lines), file=sys.stderr)
|
||||
|
||||
|
||||
|
||||
def display_success_panel(
|
||||
title: str,
|
||||
content: str,
|
||||
@@ -100,6 +103,7 @@ def display_success_panel(
|
||||
"""Display a success panel to stdout."""
|
||||
if output_format in ("json", "yaml"):
|
||||
import json as _json
|
||||
|
||||
data = {"status": "success", "title": title, "content": content}
|
||||
print(_json.dumps(data), file=sys.stdout)
|
||||
elif output_format == "plain":
|
||||
@@ -115,7 +119,6 @@ def display_success_panel(
|
||||
print(chr(10).join(lines), file=sys.stdout)
|
||||
|
||||
|
||||
|
||||
def display_table(
|
||||
title: str,
|
||||
columns: list[tuple[str, Any]],
|
||||
@@ -128,6 +131,7 @@ def display_table(
|
||||
|
||||
if output_format == "json":
|
||||
import json as _json
|
||||
|
||||
data: dict[str, Any] = {
|
||||
"title": title,
|
||||
"columns": col_names,
|
||||
@@ -205,6 +209,7 @@ class CLIOutputManager:
|
||||
message = str(exc)
|
||||
if self.output_format in ("json", "yaml"):
|
||||
import json as _json
|
||||
|
||||
print(
|
||||
_json.dumps({"status": "error", "label": label, "message": message}),
|
||||
file=sys.stderr,
|
||||
|
||||
Reference in New Issue
Block a user