Skip to content

Commit f7df204

Browse files
committed
Remove noqa: BLE001 comments from exception handlers
Eliminated all '# noqa: BLE001' comments from exception handling blocks across multiple modules. This change improves code cleanliness and removes unnecessary linter suppression comments.
1 parent 8afed71 commit f7df204

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/backend/af/callbacks/response_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def agent_response_callback(
9595
)
9696
)
9797
logger.info("%s message (agent=%s): %s", str(role).capitalize(), agent_name, text[:200])
98-
except Exception as e: # noqa: BLE001
98+
except Exception as e:
9999
logger.error("agent_response_callback error sending WebSocket message: %s", e)
100100

101101

@@ -148,5 +148,5 @@ async def streaming_agent_response_callback(
148148
message_type=WebsocketMessageType.AGENT_MESSAGE_STREAMING,
149149
)
150150
logger.debug("Streaming chunk (agent=%s final=%s len=%d)", agent_id, is_final, len(cleaned))
151-
except Exception as e: # noqa: BLE001
151+
except Exception as e:
152152
logger.error("streaming_agent_response_callback error: %s", e)

src/backend/af/magentic_agents/common/lifecycle.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ async def close(self) -> None:
5656
if self._agent and hasattr(self._agent, "close"):
5757
try:
5858
await self._agent.close() # AzureAIAgentClient has async close
59-
except Exception: # noqa: BLE001
59+
except Exception:
6060
pass
6161
# Unregister from registry if present
6262
try:
6363
agent_registry.unregister_agent(self)
64-
except Exception: # noqa: BLE001
64+
except Exception:
6565
pass
6666
await self._stack.aclose()
6767
finally:
@@ -98,7 +98,7 @@ async def _prepare_mcp_tool(self) -> None:
9898
)
9999
await self._stack.enter_async_context(mcp_tool)
100100
self.mcp_tool = mcp_tool # Store for later use
101-
except Exception: # noqa: BLE001
101+
except Exception:
102102
self.mcp_tool = None
103103

104104

@@ -154,7 +154,7 @@ async def open(self) -> "AzureAgentBase":
154154
# Register agent (best effort)
155155
try:
156156
agent_registry.register_agent(self)
157-
except Exception: # noqa: BLE001
157+
except Exception:
158158
pass
159159

160160
return self
@@ -178,25 +178,25 @@ async def close(self) -> None:
178178
if self._agent and hasattr(self._agent, "close"):
179179
try:
180180
await self._agent.close()
181-
except Exception: # noqa: BLE001
181+
except Exception:
182182
pass
183183

184184
# Unregister from registry
185185
try:
186186
agent_registry.unregister_agent(self)
187-
except Exception: # noqa: BLE001
187+
except Exception:
188188
pass
189189

190190
# Close credential and project client
191191
if self.client:
192192
try:
193193
await self.client.close()
194-
except Exception: # noqa: BLE001
194+
except Exception:
195195
pass
196196
if self.creds:
197197
try:
198198
await self.creds.close()
199-
except Exception: # noqa: BLE001
199+
except Exception:
200200
pass
201201

202202
finally:

src/backend/af/magentic_agents/proxy_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async def _wait_for_user_clarification(
164164
except KeyError:
165165
logger.debug("ProxyAgentAF: Invalid clarification request id %s", request_id)
166166
return None
167-
except Exception as ex: # noqa: BLE001
167+
except Exception as ex:
168168
logger.debug("ProxyAgentAF: Unexpected error awaiting clarification: %s", ex)
169169
orchestration_config.cleanup_clarification(request_id)
170170
return None
@@ -199,7 +199,7 @@ async def _notify_timeout(self, request_id: str) -> None:
199199
request_id,
200200
self.user_id,
201201
)
202-
except Exception as ex: # noqa: BLE001
202+
except Exception as ex:
203203
logger.error("ProxyAgentAF: Failed to send timeout notification: %s", ex)
204204
orchestration_config.cleanup_clarification(request_id)
205205

src/backend/af/magentic_agents/reasoning_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async def close(self) -> None:
152152
# Unregister from registry
153153
try:
154154
agent_registry.unregister_agent(self)
155-
except Exception: # noqa: BLE001
155+
except Exception:
156156
pass
157157

158158
finally:

src/backend/af/orchestration/human_approval_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def plan(self, magentic_context: MagenticContext) -> Any:
121121

122122
try:
123123
orchestration_config.plans[self.magentic_plan.id] = self.magentic_plan
124-
except Exception as e: # noqa: BLE001
124+
except Exception as e:
125125
logger.error("Error processing plan approval: %s", e)
126126

127127
# Send approval request
@@ -242,13 +242,13 @@ async def _wait_for_user_approval(
242242
self.current_user_id,
243243
m_plan_id,
244244
)
245-
except Exception as e: # noqa: BLE001
245+
except Exception as e:
246246
logger.error("Failed to send timeout notification: %s", e)
247247

248248
orchestration_config.cleanup_approval(m_plan_id)
249249
return None
250250

251-
except KeyError as e: # noqa: BLE001
251+
except KeyError as e:
252252
logger.debug("Plan ID not found: %s - terminating process silently", e)
253253
return None
254254

@@ -257,7 +257,7 @@ async def _wait_for_user_approval(
257257
orchestration_config.cleanup_approval(m_plan_id)
258258
return None
259259

260-
except Exception as e: # noqa: BLE001
260+
except Exception as e:
261261
logger.debug(
262262
"Unexpected error waiting for approval: %s - terminating process silently",
263263
e,

src/backend/common/utils/utils_af.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def create_RAI_agent() -> FoundryAgentTemplate:
4141

4242
try:
4343
agent_registry.register_agent(agent)
44-
except Exception as registry_error: # noqa: BLE001
44+
except Exception as registry_error:
4545
logging.warning(
4646
"Failed to register agent '%s' with registry: %s",
4747
agent.agent_name,
@@ -72,7 +72,7 @@ async def _get_agent_response(agent: FoundryAgentTemplate, query: str) -> str:
7272
if txt:
7373
parts.append(str(txt))
7474
return "".join(parts) if parts else ""
75-
except Exception as e: # noqa: BLE001
75+
except Exception as e:
7676
logging.error("Error streaming agent response: %s", e)
7777
return "TRUE" # Default to blocking on error
7878

@@ -99,15 +99,15 @@ async def rai_success(description: str) -> bool:
9999
logging.info("RAI check failed (blocked). Sample: %s...", description[:60])
100100
return False
101101

102-
except Exception as e: # noqa: BLE001
102+
except Exception as e:
103103
logging.error("RAI check error: %s — blocking by default.", e)
104104
return False
105105
finally:
106106
# Ensure we close resources
107107
if agent:
108108
try:
109109
await agent.close()
110-
except Exception: # noqa: BLE001
110+
except Exception:
111111
pass
112112

113113

@@ -160,6 +160,6 @@ async def rai_validate_team_config(team_config_json: dict) -> tuple[bool, str]:
160160
)
161161

162162
return True, ""
163-
except Exception as e: # noqa: BLE001
163+
except Exception as e:
164164
logging.error("Error validating team configuration content: %s", e)
165165
return False, "Unable to validate team configuration content. Please try again."

0 commit comments

Comments
 (0)