Skip to content

Commit 6497d67

Browse files
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>
1 parent 0700b73 commit 6497d67

2 files changed

Lines changed: 30 additions & 31 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ ignore = [
178178

179179
# Backwards-compatibility suppressions for existing code
180180
"A001", # Variable shadows built-in
181-
"A002", # Argument shadows built-in
182181
"A004", # Import shadows built-in
183182
"FBT001", # Boolean positional arg
184183
"FBT002", # Boolean default value

src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ class Spec:
7575
"""
7676

7777
@classmethod
78-
def check_id(cls, id: str | int | None, *, allow_empty: bool = False) -> None:
78+
def check_id(cls, request_id: str | int | None, *, allow_empty: bool = False) -> None:
7979
"""
80-
Value check for *id* entries. When *allow_empty* is *True*, *id* is allowed to be *None*.
81-
Raises a *TypeError* when *id* is neither an integer nor a string.
80+
Value check for *request_id* entries. When *allow_empty* is *True*, *request_id* is allowed to be *None*.
81+
Raises a *TypeError* when *request_id* is neither an integer nor a string.
8282
83-
:param id: The id to check.
84-
:param allow_empty: Whether *id* is allowed to be *None*.
83+
:param request_id: The id to check.
84+
:param allow_empty: Whether *request_id* is allowed to be *None*.
8585
:return: None.
86-
:raises TypeError: When *id* is invalid.
86+
:raises TypeError: When *request_id* is invalid.
8787
"""
88-
if (id is not None or not allow_empty) and not isinstance(id, (int, str)):
89-
raise TypeError(f"id must be an integer or string, got {id} ({type(id)})")
88+
if (request_id is not None or not allow_empty) and not isinstance(request_id, (int, str)):
89+
raise TypeError(f"id must be an integer or string, got {request_id} ({type(request_id)})")
9090

9191
@classmethod
9292
def check_method(cls, method: str, /) -> None:
@@ -120,37 +120,37 @@ def request(
120120
cls,
121121
method: str,
122122
/,
123-
id: str | int | None = None,
123+
request_id: str | int | None = None,
124124
*,
125125
params: dict[str, Any] | None = None,
126126
) -> str:
127127
"""
128128
Creates the string representation of a request that calls *method* with optional *params*
129-
which are encoded by ``json.dumps``. When *id* is *None*, the request is considered a
129+
which are encoded by ``json.dumps``. When *request_id* is *None*, the request is considered a
130130
notification.
131131
132132
:param method: The method to call.
133-
:param id: The id of the request.
133+
:param request_id: The id of the request.
134134
:param params: The parameters of the request.
135135
:return: The request string.
136-
:raises RPCInvalidRequest: When *method* or *id* are invalid.
136+
:raises RPCInvalidRequest: When *method* or *request_id* are invalid.
137137
:raises RPCParseError: When *params* could not be encoded.
138138
"""
139139
try:
140140
cls.check_method(method)
141-
cls.check_id(id, allow_empty=True)
141+
cls.check_id(request_id, allow_empty=True)
142142
except Exception as e:
143143
raise RPCInvalidRequest(str(e))
144144

145145
# start building the request string
146146
req = f'{{"jsonrpc":"2.0","method":"{method}"'
147147

148148
# add the id when given
149-
if id is not None:
149+
if request_id is not None:
150150
# encode string ids
151-
if isinstance(id, str):
152-
id = json.dumps(id)
153-
req += f',"id":{id}'
151+
if isinstance(request_id, str):
152+
request_id = json.dumps(request_id)
153+
req += f',"id":{request_id}'
154154

155155
# add parameters when given
156156
if params is not None:
@@ -165,29 +165,29 @@ def request(
165165
return req
166166

167167
@classmethod
168-
def response(cls, id: str | int | None, result: Any, /) -> str:
168+
def response(cls, request_id: str | int | None, result: Any, /) -> str:
169169
"""
170170
Creates the string representation of a respone that was triggered by a request with *id*.
171171
A *result* is required, even if it is *None*.
172172
173-
:param id: The id of the request that triggered this response.
173+
:param request_id: The id of the request that triggered this response.
174174
:param result: The result of the request.
175175
:return: The response string.
176176
:raises RPCInvalidRequest: When *id* is invalid.
177177
:raises RPCParseError: When *result* could not be encoded.
178178
"""
179179
try:
180-
cls.check_id(id)
180+
cls.check_id(request_id)
181181
except Exception as e:
182182
raise RPCInvalidRequest(str(e))
183183

184184
# encode string ids
185-
if isinstance(id, str):
186-
id = json.dumps(id)
185+
if isinstance(request_id, str):
186+
request_id = json.dumps(request_id)
187187

188188
# build the response string
189189
try:
190-
res = f'{{"jsonrpc":"2.0","id":{id},"result":{json.dumps(result)}}}'
190+
res = f'{{"jsonrpc":"2.0","id":{request_id},"result":{json.dumps(result)}}}'
191191
except Exception as e:
192192
raise RPCParseError(str(e))
193193

@@ -196,7 +196,7 @@ def response(cls, id: str | int | None, result: Any, /) -> str:
196196
@classmethod
197197
def error(
198198
cls,
199-
id: str | int | None,
199+
request_id: str | int | None,
200200
code: int,
201201
*,
202202
data: Any | None = None,
@@ -206,15 +206,15 @@ def error(
206206
*id*. *code* must lead to a registered :py:class:`RPCError`. *data* might contain
207207
additional, detailed error information and is encoded by ``json.dumps`` when set.
208208
209-
:param id: The id of the request that triggered this error.
209+
:param request_id: The id of the request that triggered this error.
210210
:param code: The error code.
211211
:param data: Additional error data.
212212
:return: The error string.
213213
:raises RPCInvalidRequest: When *id* or *code* are invalid.
214214
:raises RPCParseError: When *data* could not be encoded.
215215
"""
216216
try:
217-
cls.check_id(id)
217+
cls.check_id(request_id)
218218
cls.check_code(code)
219219
except Exception as e:
220220
raise RPCInvalidRequest(str(e))
@@ -233,11 +233,11 @@ def error(
233233
err_data += "}"
234234

235235
# encode string ids
236-
if isinstance(id, str):
237-
id = json.dumps(id)
236+
if isinstance(request_id, str):
237+
request_id = json.dumps(request_id)
238238

239239
# start building the error string
240-
err = f'{{"jsonrpc":"2.0","id":{id},"error":{err_data}}}'
240+
err = f'{{"jsonrpc":"2.0","id":{request_id},"error":{err_data}}}'
241241

242242
return err
243243

@@ -441,7 +441,7 @@ def call(
441441

442442
# create the request
443443
params = params if params else {"args": args, "kwargs": kwargs}
444-
req = Spec.request(method, id=id, params=params)
444+
req = Spec.request(method, request_id=id, params=params)
445445
print(f"-> {req}")
446446
msg = f"Content-Length: {len(req)}\r\n\r\n{req}"
447447
self._write(msg)

0 commit comments

Comments
 (0)