Skip to content

Commit c6c8b2c

Browse files
jeremyederclaudeAmbient Code
authored
fix(ci): run ruff in autofix mode (#25)
* fix(ci): run ruff in autofix mode Runs `ruff check --fix` and `ruff format` to apply auto-fixable lint and format corrections, then fails via `git diff --exit-code` if the working tree is dirty — meaning the developer forgot to run ruff locally before pushing. This gives a clear error message pointing them to the fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * style: apply ruff format to client.py Pre-commit hooks caught one file needing reformatting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: merge implicit string concatenation for ruff compliance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: rewrite tests for new public-api client - Remove obsolete tests for oc CLI-based client - Remove test_security.py (tested methods no longer exist) - Add test_formatters.py for output formatting - Update test_client.py for HTTP-based client - Update test_server.py for current 7 tools All 40 tests pass with 70% coverage. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Ambient Code <ambient-code@redhat.com>
1 parent 3689fd1 commit c6c8b2c

File tree

6 files changed

+459
-914
lines changed

6 files changed

+459
-914
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ jobs:
4848
mkdir -p ~/.config/acp
4949
cp clusters.yaml.example ~/.config/acp/clusters.yaml
5050
51-
- name: Run ruff (lint and format check)
51+
- name: Run ruff (autofix, then verify)
5252
run: |
53-
uv run ruff check .
54-
uv run ruff format --check .
53+
uv run ruff check --fix .
54+
uv run ruff format .
55+
git diff --exit-code || (echo "ruff made changes — commit them locally before pushing" && exit 1)
5556
5657
# TODO: Enable mypy once type annotations are complete
5758
# - name: Run mypy (type checking)

src/mcp_acp/client.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def _get_token(self, cluster_config: dict[str, Any]) -> str:
7979

8080
if not token:
8181
raise ValueError(
82-
"No authentication token available. "
83-
"Set 'token' in clusters.yaml or ACP_TOKEN environment variable."
82+
"No authentication token available. Set 'token' in clusters.yaml or ACP_TOKEN environment variable."
8483
)
8584

8685
return token
@@ -162,9 +161,7 @@ def _validate_input(self, value: str, field_name: str, max_length: int = 253) ->
162161
if len(value) > max_length:
163162
raise ValueError(f"{field_name} exceeds maximum length of {max_length}")
164163
if not re.match(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$", value):
165-
raise ValueError(
166-
f"{field_name} contains invalid characters. Must match DNS-1123 format."
167-
)
164+
raise ValueError(f"{field_name} contains invalid characters. Must match DNS-1123 format.")
168165

169166
def _validate_bulk_operation(self, items: list[str], operation_name: str) -> None:
170167
"""Enforce item limit for bulk operations."""
@@ -311,9 +308,7 @@ async def delete_session(self, project: str, session: str, dry_run: bool = False
311308
"message": f"Failed to delete session: {str(e)}",
312309
}
313310

314-
async def bulk_delete_sessions(
315-
self, project: str, sessions: list[str], dry_run: bool = False
316-
) -> dict[str, Any]:
311+
async def bulk_delete_sessions(self, project: str, sessions: list[str], dry_run: bool = False) -> dict[str, Any]:
317312
"""Delete multiple sessions (max 3).
318313
319314
Args:
@@ -332,15 +327,19 @@ async def bulk_delete_sessions(
332327

333328
if dry_run:
334329
if result.get("success", True):
335-
dry_run_info["would_execute"].append({
336-
"session": session,
337-
"info": result.get("session_info"),
338-
})
330+
dry_run_info["would_execute"].append(
331+
{
332+
"session": session,
333+
"info": result.get("session_info"),
334+
}
335+
)
339336
else:
340-
dry_run_info["skipped"].append({
341-
"session": session,
342-
"reason": result.get("message"),
343-
})
337+
dry_run_info["skipped"].append(
338+
{
339+
"session": session,
340+
"reason": result.get("message"),
341+
}
342+
)
344343
else:
345344
if result.get("deleted"):
346345
success.append(session)
@@ -360,13 +359,15 @@ def list_clusters(self) -> dict[str, Any]:
360359
default_cluster = self.clusters_config.default_cluster
361360

362361
for name, cluster in self.clusters_config.clusters.items():
363-
clusters.append({
364-
"name": name,
365-
"server": cluster.server,
366-
"description": cluster.description or "",
367-
"default_project": cluster.default_project,
368-
"is_default": name == default_cluster,
369-
})
362+
clusters.append(
363+
{
364+
"name": name,
365+
"server": cluster.server,
366+
"description": cluster.description or "",
367+
"default_project": cluster.default_project,
368+
"is_default": name == default_cluster,
369+
}
370+
)
370371

371372
return {"clusters": clusters, "default_cluster": default_cluster}
372373

0 commit comments

Comments
 (0)