build: configure ruff from pyproject.toml (#1100)

# What does this PR do?

- Remove hardcoded configurations from pre-commit.
- Allow configuration to be set via pyproject.toml.
- Merge .ruff.toml settings into pyproject.toml.
- Ensure the linter and formatter use the defined configuration instead
of being overridden by pre-commit.

Signed-off-by: Sébastien Han <seb@redhat.com>

[//]: # (If resolving an issue, uncomment and update the line below)
[//]: # (Closes #[issue-number])

## Test Plan
[Describe the tests you ran to verify your changes with result
summaries. *Provide clear instructions so the plan can be easily
re-executed.*]

[//]: # (## Documentation)

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han 2025-02-14 18:01:57 +01:00 committed by GitHub
parent a3cb039e83
commit c0ee512980
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 78 additions and 62 deletions

View file

@ -41,7 +41,7 @@ class ShieldRunnerMixin:
for identifier in identifiers
]
)
for identifier, response in zip(identifiers, responses):
for identifier, response in zip(identifiers, responses, strict=False):
if not response.violation:
continue

View file

@ -201,7 +201,9 @@ class MetaReferenceEvalImpl(
raise ValueError(f"Invalid candidate type: {candidate.type}")
# scoring with generated_answer
score_input_rows = [input_r | generated_r for input_r, generated_r in zip(input_rows, generations)]
score_input_rows = [
input_r | generated_r for input_r, generated_r in zip(input_rows, generations, strict=False)
]
if task_config.scoring_params is not None:
scoring_functions_dict = {

View file

@ -83,12 +83,6 @@ import sys as _sys
from contextlib import ( # noqa
contextmanager as _contextmanager,
)
from contextlib import (
redirect_stderr as _redirect_stderr,
)
from contextlib import (
redirect_stdout as _redirect_stdout,
)
from multiprocessing.connection import Connection as _Connection
# Mangle imports to avoid polluting model execution namespace.

View file

@ -118,7 +118,7 @@ class MemoryToolRuntimeImpl(ToolsProtocolPrivate, ToolRuntime, RAGToolRuntime):
return RAGQueryResult(content=None)
# sort by score
chunks, scores = zip(*sorted(zip(chunks, scores), key=lambda x: x[1], reverse=True))
chunks, scores = zip(*sorted(zip(chunks, scores, strict=False), key=lambda x: x[1], reverse=True), strict=False)
tokens = 0
picked = []

View file

@ -103,7 +103,7 @@ class FaissIndex(EmbeddingIndex):
chunks = []
scores = []
for d, i in zip(distances[0], indices[0]):
for d, i in zip(distances[0], indices[0], strict=False):
if i < 0:
continue
chunks.append(self.chunk_by_index[int(i)])

View file

@ -80,7 +80,7 @@ class SQLiteVecIndex(EmbeddingIndex):
try:
# Start transaction
cur.execute("BEGIN TRANSACTION")
for chunk, emb in zip(chunks, embeddings):
for chunk, emb in zip(chunks, embeddings, strict=False):
# Serialize and insert the chunk metadata.
chunk_json = chunk.model_dump_json()
cur.execute(f"INSERT INTO {self.metadata_table} (chunk) VALUES (?)", (chunk_json,))