Skip to content

Commit d899679

Browse files
authored
Merge pull request #2790 from tisnik/lcore-3722-enable-ble-ruff-rules-on-ci
LCORE-3722: Enable BLE Ruff rules on CI
2 parents f6ff9a4 + d4c128a commit d899679

9 files changed

Lines changed: 24 additions & 26 deletions

File tree

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ line-length = 88
252252
extend-exclude = ["tests/profiles/syntax_error.py"]
253253

254254
[tool.ruff.lint]
255-
extend-select = ["C", "FA", "FLY", "I", "TID251", "UP006", "UP007", "UP008", "UP010", "UP012", "UP017", "UP024", "UP035", "UP040", "UP041", "RUF100", "B009", "B010", "B011", "DTZ005", "D202", "PLR1733", "RUF022", "PLW1510", "TC004", "PIE790", "PERF402", "FURB129", "RET501", "LOG"]
256-
ignore = ["UP047", "UP045", "BLE", "S", "C901", "RUF", "SIM", "B017", "TRY004", "TRY201", "TRY203", "TRY401", "B008", "EXE001", "G201", "ISC004", "PYI034", "PYI064"]
255+
extend-select = ["C", "FA", "FLY", "I", "TID251", "UP006", "UP007", "UP008", "UP010", "UP012", "UP017", "UP024", "UP035", "UP040", "UP041", "RUF100", "B009", "B010", "B011", "BLE", "DTZ005", "D202", "PLR1733", "RUF022", "PLW1510", "TC004", "PIE790", "PERF402", "FURB129", "RET501", "LOG"]
256+
ignore = ["UP047", "UP045", "S", "C901", "RUF", "SIM", "B017", "TRY004", "TRY201", "TRY203", "TRY401", "B008", "EXE001", "G201", "ISC004", "PYI034", "PYI064"]
257257

258258
[tool.ruff.lint.flake8-tidy-imports.banned-api]
259259
unittest = { msg = "use pytest instead of unittest" }

‎src/app/endpoints/a2a.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ async def _handle_a2a_jsonrpc( # pylint: disable=too-many-locals,too-many-state
10861086
logger.warning(
10871087
"Could not parse A2A request body for method detection: %s", str(e)
10881088
)
1089-
except Exception as e: # pylint: disable=broad-except
1089+
except Exception as e: # pylint: disable=broad-except # noqa: BLE001
10901090
logger.error("Error detecting streaming request: %s", str(e))
10911091

10921092
with tracer.start_as_current_span("a2a.dispatch") as span:

‎src/app/endpoints/vector_stores.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,9 @@ async def add_file_to_vector_store( # pylint: disable=too-many-locals,too-many-
750750
):
751751
try:
752752
await client.files.delete(body.file_id)
753-
except Exception as delete_error: # pylint: disable=broad-exception-caught
753+
except (
754+
Exception # pylint: disable=broad-exception-caught # noqa: BLE001
755+
) as delete_error:
754756
logger.warning(
755757
"Failed to delete file %s after vector store attach: %s",
756758
body.file_id,

‎src/authentication/k8s.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def get_user_info(token: str) -> Optional[kubernetes.client.V1TokenReviewStatus]
382382
cause=f"Kubernetes API request failed: {e.reason} (status {e.status})",
383383
)
384384
raise HTTPException(**response_obj.model_dump()) from e
385-
except Exception as e: # pylint: disable=broad-exception-caught
385+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
386386
logger.error("Unexpected error during TokenReview: %s", e)
387387
return None
388388

‎src/cache/sqlite_cache.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ def connected(self) -> bool:
230230
if cursor is not None:
231231
try:
232232
cursor.close()
233-
except Exception: # pylint: disable=broad-exception-caught
233+
except (
234+
Exception # pylint: disable=broad-exception-caught # noqa: BLE001
235+
):
234236
logger.warning("Unable to close cursor")
235237

236238
def initialize_cache(self) -> None:

‎src/runners/quota_scheduler.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def quota_scheduler(config: QuotaHandlersConfiguration) -> bool:
6262
# if connection is established, we are ok
6363
if connection is not None:
6464
break
65-
except Exception as e: # pylint: disable=broad-exception-caught
65+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
6666
logger.warning("Can not connect to database, will try later: %s", e)
6767
sleep(config.scheduler.database_reconnection_delay)
6868
else:
@@ -99,7 +99,9 @@ def quota_scheduler(config: QuotaHandlersConfiguration) -> bool:
9999
try:
100100
if connection is not None:
101101
connection.close()
102-
except Exception: # pylint: disable=broad-exception-caught
102+
except ( # pylint: disable=broad-exception-caught
103+
Exception # noqa: BLE001
104+
):
103105
pass # Connection already dead
104106
connection = connect(config)
105107
if connection is None:
@@ -108,7 +110,9 @@ def quota_scheduler(config: QuotaHandlersConfiguration) -> bool:
108110
quota_revocation(
109111
connection, limiter, increase_quota_statement, reset_quota_statement
110112
)
111-
except Exception as e: # pylint: disable=broad-exception-caught
113+
except (
114+
Exception # pylint: disable=broad-exception-caught # noqa: BLE001
115+
) as e:
112116
logger.error("Quota revoke error: %s", e)
113117
logger.info("Quota scheduler sync finished")
114118
sleep(period)
@@ -138,7 +142,7 @@ def connected(connection: Any) -> bool:
138142
cursor.close()
139143
logger.info("Connection to storage is ok")
140144
return True
141-
except Exception as e: # pylint: disable=broad-exception-caught
145+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
142146
logger.error("Disconnected from storage: %s", e)
143147
return False
144148

‎src/utils/query.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def update_conversation_topic_summary(
456456
configuration.conversation_cache.set_topic_summary(
457457
user_id, conversation_id, topic_summary, skip_userid_check
458458
)
459-
except Exception as e: # pylint: disable=broad-except # noqa: BLE001 RUF100
459+
except Exception as e: # pylint: disable=broad-except # noqa: BLE001
460460
logger.warning(
461461
"Failed to update topic summary in cache for %s: %s",
462462
normalized_id,

‎src/utils/reranker.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ async def _get_cross_encoder(model_name: str) -> Any:
5050
model = await asyncio.to_thread(CrossEncoder, model_name)
5151
_cross_encoder_models[model_name] = model
5252
logger.info("Loaded cross-encoder for RAG reranking: %s", model_name)
53-
except (
54-
Exception # pylint: disable=broad-exception-caught # noqa: BLE001 RUF100
55-
) as e:
53+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
5654
logger.warning(
5755
"Could not load cross-encoder for reranking (%s): %s", model_name, e
5856
)
@@ -170,9 +168,7 @@ async def rerank_chunks_with_cross_encoder(
170168
for score, chunk in top_indexed
171169
]
172170

173-
except (
174-
Exception # pylint: disable=broad-exception-caught # noqa: BLE001 RUF100
175-
) as e:
171+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
176172
logger.warning(
177173
"Cross-encoder reranking failed, falling back to original scoring: %s", e
178174
)

‎src/utils/vector_search.py‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ async def _query_store_for_byok_rag( # pylint: disable=too-many-arguments,too-m
296296
},
297297
)
298298
return _extract_byok_rag_chunks(search_response, vector_store_id, weight)
299-
except (
300-
Exception # pylint: disable=broad-exception-caught # noqa: BLE001 RUF100
301-
) as e:
299+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
302300
logger.warning("Failed to search '%s': %s", vector_store_id, e)
303301
return []
304302

@@ -569,9 +567,7 @@ async def _fetch_byok_rag( # pylint: disable=too-many-locals
569567
# Extract referenced documents from BYOK RAG chunks (now with resolved sources)
570568
referenced_documents = _process_byok_rag_chunks_for_documents(top_results)
571569

572-
except (
573-
Exception # pylint: disable=broad-exception-caught # noqa: BLE001 RUF100
574-
) as e:
570+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
575571
logger.warning("Failed to perform BYOK RAG search: %s", e)
576572
logger.debug("BYOK RAG error details: %s", traceback.format_exc())
577573

@@ -640,9 +636,7 @@ async def _fetch_okp_rag( # pylint: disable=too-many-locals
640636
)
641637
logger.debug("OKP RAG returned %d chunks", len(rag_chunks))
642638

643-
except (
644-
Exception # pylint: disable=broad-exception-caught # noqa: BLE001 RUF100
645-
) as e:
639+
except Exception as e: # pylint: disable=broad-exception-caught # noqa: BLE001
646640
logger.warning("Failed to query OKP for chunks: %s", e)
647641
logger.debug("OKP query error details: %s", traceback.format_exc())
648642

0 commit comments

Comments
 (0)