Skip to content

Commit e9d29cd

Browse files
rcholicclaude
andcommitted
fix: Resolve pre-commit linting issues
- Fixed mypy error in openclaw_adapter.py:125 by casting dict value to str - Fixed flake8 F541 in openclaw_browser_automation.py (removed f-string without placeholder) - Fixed flake8 F841 in openclaw_browser_automation.py (unused result variable) - Applied isort formatting All pre-commit hooks now pass: - isort, flake8, mypy, bandit, black, pyupgrade - All 127 tests passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d09461f commit e9d29cd

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

examples/openclaw_browser_automation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def main():
9999
try:
100100
# Run the OpenClaw task with authorization
101101
result = secure_agent.run(task=task)
102-
print(f"\n[OpenClaw] Task completed successfully")
102+
print("\n[OpenClaw] Task completed successfully")
103103
print(f"Return code: {result.get('returncode', 'N/A')}")
104104
print(f"Output: {result.get('stdout', '')[:200]}...")
105105
except Exception as e:
@@ -124,6 +124,7 @@ def example_with_debug_mode():
124124
try:
125125
result = secure_agent.run(task=task)
126126
print("\n[Debug] Task trace complete")
127+
print(f"Result: {result}")
127128
except Exception as e:
128129
print(f"\n[Debug] Error occurred: {e}")
129130

src/predicate_secure/openclaw_adapter.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
import os
1414
import subprocess
1515
import threading
16+
from collections.abc import Callable
1617
from dataclasses import dataclass
1718
from http.server import BaseHTTPRequestHandler, HTTPServer
18-
from typing import Any, Callable
19+
from typing import Any
1920
from urllib.parse import urlparse
2021

2122

@@ -121,7 +122,7 @@ def _extract_resource(self, data: dict) -> str:
121122
return f"element:{data['elementId']}"
122123
# For predicate-snapshot, resource is the current page
123124
if "url" in data:
124-
return data["url"]
125+
return str(data["url"])
125126
return "*"
126127

127128
def _send_json_response(self, status: int, data: dict) -> None:
@@ -165,7 +166,9 @@ def set_authorizer(self, authorizer: Callable[[str, dict], bool]) -> None:
165166
self._authorizer = authorizer
166167
SkillProxyHandler.authorizer = self._wrap_authorizer(authorizer)
167168

168-
def _wrap_authorizer(self, authorizer: Callable[[str, dict], bool]) -> Callable[[str, dict], bool]:
169+
def _wrap_authorizer(
170+
self, authorizer: Callable[[str, dict], bool]
171+
) -> Callable[[str, dict], bool]:
169172
"""Wrap authorizer to handle predicate-authority integration."""
170173

171174
def wrapped(action: str, context: dict) -> bool:

tests/test_openclaw_adapter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
from predicate_secure import SecureAgent
66
from predicate_secure.detection import Framework, FrameworkDetector
7-
from predicate_secure.openclaw_adapter import OpenClawAdapter, OpenClawConfig, create_openclaw_adapter
7+
from predicate_secure.openclaw_adapter import (
8+
OpenClawAdapter,
9+
OpenClawConfig,
10+
create_openclaw_adapter,
11+
)
812

913

1014
class TestOpenClawConfig:
@@ -60,6 +64,7 @@ def test_detect_openclaw_with_process_attribute(self):
6064

6165
class MockOpenClawWrapper:
6266
__module__ = "not_openclaw_module" # Force module check to fail
67+
6368
def __init__(self):
6469
self.openclaw_process = None
6570
self.openclaw_config = {}

0 commit comments

Comments
 (0)