From 0700b733d2cde3d49243fdfe43c6bc3b70ebd8e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:12:02 +0000 Subject: [PATCH 1/2] Initial plan From 6497d67bcb243b641ce6fa390bc03afab3be4a69 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:25:21 +0000 Subject: [PATCH 2/2] Fix A002 linter error: rename id parameter to request_id in Spec class Agent-Logs-Url: https://github.com/GitHubSecurityLab/seclab-taskflow-agent/sessions/c5f089f2-6b83-41f3-97c7-a4d4417ef555 Co-authored-by: kevinbackhouse <4358136+kevinbackhouse@users.noreply.github.com> --- pyproject.toml | 1 - .../mcp_servers/codeql/jsonrpyc/__init__.py | 60 +++++++++---------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f6de0e4..ffe05dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -178,7 +178,6 @@ ignore = [ # Backwards-compatibility suppressions for existing code "A001", # Variable shadows built-in - "A002", # Argument shadows built-in "A004", # Import shadows built-in "FBT001", # Boolean positional arg "FBT002", # Boolean default value diff --git a/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py b/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py index 8d14d96..aabfe47 100644 --- a/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py +++ b/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py @@ -75,18 +75,18 @@ class Spec: """ @classmethod - def check_id(cls, id: str | int | None, *, allow_empty: bool = False) -> None: + def check_id(cls, request_id: str | int | None, *, allow_empty: bool = False) -> None: """ - Value check for *id* entries. When *allow_empty* is *True*, *id* is allowed to be *None*. - Raises a *TypeError* when *id* is neither an integer nor a string. + Value check for *request_id* entries. When *allow_empty* is *True*, *request_id* is allowed to be *None*. + Raises a *TypeError* when *request_id* is neither an integer nor a string. - :param id: The id to check. - :param allow_empty: Whether *id* is allowed to be *None*. + :param request_id: The id to check. + :param allow_empty: Whether *request_id* is allowed to be *None*. :return: None. - :raises TypeError: When *id* is invalid. + :raises TypeError: When *request_id* is invalid. """ - if (id is not None or not allow_empty) and not isinstance(id, (int, str)): - raise TypeError(f"id must be an integer or string, got {id} ({type(id)})") + if (request_id is not None or not allow_empty) and not isinstance(request_id, (int, str)): + raise TypeError(f"id must be an integer or string, got {request_id} ({type(request_id)})") @classmethod def check_method(cls, method: str, /) -> None: @@ -120,25 +120,25 @@ def request( cls, method: str, /, - id: str | int | None = None, + request_id: str | int | None = None, *, params: dict[str, Any] | None = None, ) -> str: """ Creates the string representation of a request that calls *method* with optional *params* - which are encoded by ``json.dumps``. When *id* is *None*, the request is considered a + which are encoded by ``json.dumps``. When *request_id* is *None*, the request is considered a notification. :param method: The method to call. - :param id: The id of the request. + :param request_id: The id of the request. :param params: The parameters of the request. :return: The request string. - :raises RPCInvalidRequest: When *method* or *id* are invalid. + :raises RPCInvalidRequest: When *method* or *request_id* are invalid. :raises RPCParseError: When *params* could not be encoded. """ try: cls.check_method(method) - cls.check_id(id, allow_empty=True) + cls.check_id(request_id, allow_empty=True) except Exception as e: raise RPCInvalidRequest(str(e)) @@ -146,11 +146,11 @@ def request( req = f'{{"jsonrpc":"2.0","method":"{method}"' # add the id when given - if id is not None: + if request_id is not None: # encode string ids - if isinstance(id, str): - id = json.dumps(id) - req += f',"id":{id}' + if isinstance(request_id, str): + request_id = json.dumps(request_id) + req += f',"id":{request_id}' # add parameters when given if params is not None: @@ -165,29 +165,29 @@ def request( return req @classmethod - def response(cls, id: str | int | None, result: Any, /) -> str: + def response(cls, request_id: str | int | None, result: Any, /) -> str: """ Creates the string representation of a respone that was triggered by a request with *id*. A *result* is required, even if it is *None*. - :param id: The id of the request that triggered this response. + :param request_id: The id of the request that triggered this response. :param result: The result of the request. :return: The response string. :raises RPCInvalidRequest: When *id* is invalid. :raises RPCParseError: When *result* could not be encoded. """ try: - cls.check_id(id) + cls.check_id(request_id) except Exception as e: raise RPCInvalidRequest(str(e)) # encode string ids - if isinstance(id, str): - id = json.dumps(id) + if isinstance(request_id, str): + request_id = json.dumps(request_id) # build the response string try: - res = f'{{"jsonrpc":"2.0","id":{id},"result":{json.dumps(result)}}}' + res = f'{{"jsonrpc":"2.0","id":{request_id},"result":{json.dumps(result)}}}' except Exception as e: raise RPCParseError(str(e)) @@ -196,7 +196,7 @@ def response(cls, id: str | int | None, result: Any, /) -> str: @classmethod def error( cls, - id: str | int | None, + request_id: str | int | None, code: int, *, data: Any | None = None, @@ -206,7 +206,7 @@ def error( *id*. *code* must lead to a registered :py:class:`RPCError`. *data* might contain additional, detailed error information and is encoded by ``json.dumps`` when set. - :param id: The id of the request that triggered this error. + :param request_id: The id of the request that triggered this error. :param code: The error code. :param data: Additional error data. :return: The error string. @@ -214,7 +214,7 @@ def error( :raises RPCParseError: When *data* could not be encoded. """ try: - cls.check_id(id) + cls.check_id(request_id) cls.check_code(code) except Exception as e: raise RPCInvalidRequest(str(e)) @@ -233,11 +233,11 @@ def error( err_data += "}" # encode string ids - if isinstance(id, str): - id = json.dumps(id) + if isinstance(request_id, str): + request_id = json.dumps(request_id) # start building the error string - err = f'{{"jsonrpc":"2.0","id":{id},"error":{err_data}}}' + err = f'{{"jsonrpc":"2.0","id":{request_id},"error":{err_data}}}' return err @@ -441,7 +441,7 @@ def call( # create the request params = params if params else {"args": args, "kwargs": kwargs} - req = Spec.request(method, id=id, params=params) + req = Spec.request(method, request_id=id, params=params) print(f"-> {req}") msg = f"Content-Length: {len(req)}\r\n\r\n{req}" self._write(msg)