Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
lferran committed Mar 6, 2025
1 parent b3c840b commit cb11317
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions nucliadb/src/nucliadb/ingest/orm/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ async def _apply_extracted_vectors(
for field_vectors in fields_vectors:
# Bw/c with extracted vectors without vectorsets
if not field_vectors.vectorset_id:
assert (
len(vectorsets) == 1
), "Invalid broker message, can't ingest vectors from unknown vectorset to KB with multiple vectorsets"
assert len(vectorsets) == 1, (
"Invalid broker message, can't ingest vectors from unknown vectorset to KB with multiple vectorsets"
)
vectorset = list(vectorsets.values())[0]

else:
Expand Down
6 changes: 3 additions & 3 deletions nucliadb/tests/ingest/integration/orm/test_orm_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ async def test_vector_duplicate_fields(
for vectorset_id, vectorset_sentences in paragraph.vectorsets_sentences.items():
for vector_id, sentence in vectorset_sentences.sentences.items():
count += 1
assert (
len(sentence.vector) == 768
), f"bad key {len(sentence.vector)} {field_id} - {paragraph_id} - {vectorset_id} - {vector_id}"
assert len(sentence.vector) == 768, (
f"bad key {len(sentence.vector)} {field_id} - {paragraph_id} - {vectorset_id} - {vector_id}"
)

assert count == 1

Expand Down
18 changes: 9 additions & 9 deletions nucliadb/tests/nucliadb/integration/search/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,9 @@ async def _test_filtering(nucliadb_reader: AsyncClient, kbid: str, filters):
]

# Check that only the expected paragraphs were returned
assert len(paragraphs) == len(
expected_paragraphs
), f"{filters}\n{paragraphs}\n{expected_paragraphs}"
assert len(paragraphs) == len(expected_paragraphs), (
f"{filters}\n{paragraphs}\n{expected_paragraphs}"
)
not_yet_found = expected_paragraphs.copy()
for par in paragraphs:
if par["text"] not in expected_paragraphs:
Expand Down Expand Up @@ -450,17 +450,17 @@ async def test_search(filter_expression, expected_paragraphs):
print("expected", expected_paragraphs)

# Check that only the expected paragraphs were returned
assert len(paragraphs) == len(
expected_paragraphs
), f"{filter_expression}\n{paragraphs}\n{expected_paragraphs}"
assert len(paragraphs) == len(expected_paragraphs), (
f"{filter_expression}\n{paragraphs}\n{expected_paragraphs}"
)
not_yet_found = expected_paragraphs.copy()
for par in paragraphs:
if par["text"] not in expected_paragraphs:
raise AssertionError(f"Paragraph not expected: {par['text']}")
if par["text"] in not_yet_found:
assert (
par["score_type"] == "BOTH"
), f"Score type not expected with filters {filter_expression}"
assert par["score_type"] == "BOTH", (
f"Score type not expected with filters {filter_expression}"
)
not_yet_found.remove(par["text"])
assert len(not_yet_found) == 0, f"Some paragraphs were not found: {not_yet_found}"

Expand Down
12 changes: 6 additions & 6 deletions nucliadb/tests/nucliadb/integration/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,13 @@ async def test_find_keyword_filters(
)
assert resp.status_code == 200, f"Keyword filters: {keyword_filters}"
body = resp.json()
assert len(body["resources"]) == len(
expected_rids
), f"Keyword filters: {keyword_filters}, expected rids: {expected_rids}"
assert len(body["resources"]) == len(expected_rids), (
f"Keyword filters: {keyword_filters}, expected rids: {expected_rids}"
)
for rid in expected_rids:
assert (
rid in body["resources"]
), f"Keyword filters: {keyword_filters}, expected rids: {expected_rids}"
assert rid in body["resources"], (
f"Keyword filters: {keyword_filters}, expected rids: {expected_rids}"
)


@pytest.mark.deploy_modes("standalone")
Expand Down
6 changes: 3 additions & 3 deletions nucliadb/tests/utils/broker_messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def _apply_fields(self):
pass

elif field.id.field_type == rpb.FieldType.TEXT:
assert (
field.extracted.text is not None
), "only text fields with extracted data are supported nowadays"
assert field.extracted.text is not None, (
"only text fields with extracted data are supported nowadays"
)

elif field.id.field_type == rpb.FieldType.FILE:
file_field = self.bm.files[field.id.field]
Expand Down
6 changes: 3 additions & 3 deletions nucliadb/tests/writer/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ async def test_create_resource_async(
assert "elapsed" in data
assert data["elapsed"] is None
rid = data["uuid"]
assert (
await datamanagers.atomic.resources.resource_exists(kbid=kbid, rid=rid)
) is False, "shouldn't be ingest yet"
assert (await datamanagers.atomic.resources.resource_exists(kbid=kbid, rid=rid)) is False, (
"shouldn't be ingest yet"
)
assert spy.call_args.kwargs["wait"] is False


Expand Down
6 changes: 3 additions & 3 deletions nucliadb_sdk/src/nucliadb_sdk/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ async def init_fixture(
kbid = kb_obj.uuid

import_resp = requests.get(dataset_location)
assert (
import_resp.status_code == 200
), f"Error pulling dataset {dataset_location}:{import_resp.status_code}"
assert import_resp.status_code == 200, (
f"Error pulling dataset {dataset_location}:{import_resp.status_code}"
)
import_data = import_resp.content

import_id = sdk.start_import(kbid=kbid, content=import_data).import_id
Expand Down
6 changes: 3 additions & 3 deletions nucliadb_utils/src/nucliadb_utils/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def remove_listener(self, listener_id: str):

async def dispatch(self, payload: Any):
"""Send signal to all registered callbacks by they priority order."""
assert isinstance(
payload, self.payload_model_type
), "Can't dispatch a signal with an invalid model"
assert isinstance(payload, self.payload_model_type), (
"Can't dispatch a signal with an invalid model"
)

awaitables = [
cb(payload=payload)
Expand Down

0 comments on commit cb11317

Please sign in to comment.