Skip to content

Commit 8292287

Browse files
committed
Quiet lint noise on dispatcher and CLI-shaped signatures
The MCP stdio dispatcher intentionally catches Exception so a single bad tool call never aborts the loop; flags W0212 by going through a module-level generator instead of touching registry internals. SMBClient and FileLock get narrow pylint disables where a flat kwargs constructor and a single long-lived file handle are the point.
1 parent ee0452c commit 8292287

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

automation_file/core/file_lock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def acquire(self) -> None:
5050
if self._owned:
5151
raise LockTimeoutException(f"lock {self._path} already held by this instance")
5252
self._path.parent.mkdir(parents=True, exist_ok=True)
53+
# pylint: disable=consider-using-with
5354
fh = open(self._path, "a+b") # noqa: SIM115 — held across acquire/release
5455
try:
5556
self._acquire_os_lock(fh)

automation_file/remote/smb/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _import_smbclient() -> Any:
4343
class SMBClient:
4444
"""Minimal SMB client scoped to the operations used by this project."""
4545

46-
def __init__(
46+
def __init__( # pylint: disable=too-many-arguments,too-many-positional-arguments
4747
self,
4848
server: str,
4949
share: str,

automation_file/server/mcp_server.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def handle_message(self, message: dict[str, Any]) -> dict[str, Any] | None:
8888
return _error_response(msg_id, _METHOD_NOT_FOUND, f"unknown method: {method}")
8989
except MCPServerException as error:
9090
return _error_response(msg_id, _INVALID_PARAMS, str(error))
91-
except Exception as error:
91+
except Exception as error: # pylint: disable=broad-exception-caught
9292
file_automation_logger.warning("mcp_server: internal error: %r", error)
9393
return _error_response(msg_id, _INTERNAL_ERROR, f"{type(error).__name__}: {error}")
9494

@@ -125,16 +125,7 @@ def _handle_initialize(self, _params: dict[str, Any]) -> dict[str, Any]:
125125
}
126126

127127
def _handle_tools_list(self) -> dict[str, Any]:
128-
tools = []
129-
for name, command in sorted(self._registry.event_dict.items()):
130-
tools.append(
131-
{
132-
"name": name,
133-
"description": _describe(command),
134-
"inputSchema": _schema_for(command),
135-
}
136-
)
137-
return {"tools": tools}
128+
return {"tools": list(_catalogue(self._registry))}
138129

139130
def _handle_tools_call(self, params: dict[str, Any]) -> dict[str, Any]:
140131
name = params.get("name")
@@ -231,8 +222,16 @@ def tools_from_registry(registry: ActionRegistry) -> Iterable[dict[str, Any]]:
231222
Exposed separately so GUIs and tests can render the same catalogue
232223
without instantiating :class:`MCPServer`.
233224
"""
234-
server = MCPServer(registry)
235-
yield from server._handle_tools_list()["tools"]
225+
yield from _catalogue(registry)
226+
227+
228+
def _catalogue(registry: ActionRegistry) -> Iterable[dict[str, Any]]:
229+
for name, command in sorted(registry.event_dict.items()):
230+
yield {
231+
"name": name,
232+
"description": _describe(command),
233+
"inputSchema": _schema_for(command),
234+
}
236235

237236

238237
def _filtered_registry(source: ActionRegistry, allowed: Sequence[str]) -> ActionRegistry:

0 commit comments

Comments
 (0)