Skip to content

Commit 48e85d9

Browse files
committed
Update pre-commit
1 parent be5606f commit 48e85d9

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- --fuzzy-match-generates-todo
1212

1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.8.1
14+
rev: v0.9.7
1515
hooks:
1616
- id: ruff
1717
args: [--fix]

src/distilabel/distiset.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ def load_from_disk(
515515
)
516516
dest_distiset_path = distiset_path
517517

518-
assert fs.isdir(
519-
original_distiset_path
520-
), "`distiset_path` must be a `PathLike` object pointing to a folder or a URI of a remote filesystem."
518+
assert fs.isdir(original_distiset_path), (
519+
"`distiset_path` must be a `PathLike` object pointing to a folder or a URI of a remote filesystem."
520+
)
521521

522522
has_config = False
523523
has_artifacts = False

src/distilabel/steps/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _infer_step_name(
101101
base_name = "_".join(parts[:-1])
102102
while name in step_names:
103103
idx = int(name.split("_")[-1])
104-
name = f"{base_name}_{idx+1}"
104+
name = f"{base_name}_{idx + 1}"
105105
return name
106106

107107

src/distilabel/steps/tasks/math_shepherd/completer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def _auto_label(
485485
self._logger.info("Completer failed due to empty completion")
486486
continue
487487
if completion[-1] == golden_answers[instruction_i]:
488-
label = f" { self.tags[0]}"
488+
label = f" {self.tags[0]}"
489489
# If we found one, it's enough as we are doing Hard Estimation
490490
continue
491491
# In case we had no solutions from the previous step, otherwise we would have

src/distilabel/utils/mkdocs/components_gallery.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ def _generate_steps_pages(self, src_dir: Path, steps: list) -> List[str]:
315315
docstring["icon"] = _STEPS_CATEGORY_TO_ICON.get(first_category, "")
316316

317317
if docstring["icon"]:
318-
assert (
319-
docstring["icon"] in _STEPS_CATEGORY_TO_ICON.values()
320-
), f"Icon {docstring['icon']} not found in _STEPS_CATEGORY_TO_ICON"
318+
assert docstring["icon"] in _STEPS_CATEGORY_TO_ICON.values(), (
319+
f"Icon {docstring['icon']} not found in _STEPS_CATEGORY_TO_ICON"
320+
)
321321

322322
name = step["name"]
323323

@@ -383,9 +383,9 @@ def _generate_tasks_pages(self, src_dir: Path, tasks: list) -> List[str]:
383383
first_category = docstring["categories"][0]
384384
docstring["icon"] = _STEPS_CATEGORY_TO_ICON.get(first_category, "")
385385
if docstring["icon"]:
386-
assert (
387-
docstring["icon"] in _STEPS_CATEGORY_TO_ICON.values()
388-
), f"Icon {docstring['icon']} not found in _STEPS_CATEGORY_TO_ICON"
386+
assert docstring["icon"] in _STEPS_CATEGORY_TO_ICON.values(), (
387+
f"Icon {docstring['icon']} not found in _STEPS_CATEGORY_TO_ICON"
388+
)
389389

390390
name = task["name"]
391391

tests/unit/models/embeddings/test_llamacpp.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def test_normalize_embeddings(self, test_inputs):
115115
for result in results:
116116
# Check if the embedding is normalized (L2 norm should be close to 1)
117117
norm = np.linalg.norm(result)
118-
assert np.isclose(
119-
norm, 1.0, atol=1e-6
120-
), f"Norm is {norm}, expected close to 1.0"
118+
assert np.isclose(norm, 1.0, atol=1e-6), (
119+
f"Norm is {norm}, expected close to 1.0"
120+
)
121121

122122
def test_normalize_embeddings_false(self, test_inputs):
123123
"""
@@ -129,15 +129,15 @@ def test_normalize_embeddings_false(self, test_inputs):
129129
for result in results:
130130
# Check if the embedding is not normalized (L2 norm should not be close to 1)
131131
norm = np.linalg.norm(result)
132-
assert not np.isclose(
133-
norm, 1.0, atol=1e-6
134-
), f"Norm is {norm}, expected not close to 1.0"
132+
assert not np.isclose(norm, 1.0, atol=1e-6), (
133+
f"Norm is {norm}, expected not close to 1.0"
134+
)
135135

136136
# Additional check: ensure that at least one embedding has a norm significantly different from 1
137137
norms = [np.linalg.norm(result) for result in results]
138-
assert any(
139-
not np.isclose(norm, 1.0, atol=0.1) for norm in norms
140-
), "Expected at least one embedding with norm not close to 1.0"
138+
assert any(not np.isclose(norm, 1.0, atol=0.1) for norm in norms), (
139+
"Expected at least one embedding with norm not close to 1.0"
140+
)
141141

142142
def test_encode_batch(self) -> None:
143143
"""
@@ -149,20 +149,20 @@ def test_encode_batch(self) -> None:
149149
inputs = [f"This is test sentence {i}" for i in range(batch_size)]
150150
results = self.embeddings.encode(inputs=inputs)
151151

152-
assert (
153-
len(results) == batch_size
154-
), f"Expected {batch_size} results, got {len(results)}"
152+
assert len(results) == batch_size, (
153+
f"Expected {batch_size} results, got {len(results)}"
154+
)
155155
for result in results:
156-
assert (
157-
len(result) == 384
158-
), f"Expected embedding dimension 384, got {len(result)}"
156+
assert len(result) == 384, (
157+
f"Expected embedding dimension 384, got {len(result)}"
158+
)
159159

160160
# Test with a large batch to ensure it doesn't cause issues
161161
large_batch = ["Large batch test" for _ in range(100)]
162162
large_results = self.embeddings.encode(inputs=large_batch)
163-
assert (
164-
len(large_results) == 100
165-
), f"Expected 100 results for large batch, got {len(large_results)}"
163+
assert len(large_results) == 100, (
164+
f"Expected 100 results for large batch, got {len(large_results)}"
165+
)
166166

167167
def test_encode_batch_consistency(self) -> None:
168168
"""
@@ -180,6 +180,6 @@ def test_encode_batch_consistency(self) -> None:
180180
batch_result = self.embeddings.encode([input_text, "Another sentence"])[0]
181181

182182
# Compare the embeddings
183-
assert np.allclose(
184-
single_result, batch_result, atol=1e-5
185-
), "Embeddings are not consistent between single and batch processing"
183+
assert np.allclose(single_result, batch_result, atol=1e-5), (
184+
"Embeddings are not consistent between single and batch processing"
185+
)

0 commit comments

Comments
 (0)