Skip to content

Commit 6690bd6

Browse files
authored
Merge pull request #1775 from roboflow/pre-commit-ci-update-config
chore(pre_commit): ⬆ pre_commit autoupdate
2 parents 1c489ef + 8881b5c commit 6690bd6

File tree

13 files changed

+109
-111
lines changed

13 files changed

+109
-111
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ repos:
2525
- id: mixed-line-ending
2626

2727
- repo: https://github.com/PyCQA/bandit
28-
rev: '1.8.0'
28+
rev: '1.8.3'
2929
hooks:
3030
- id: bandit
3131
args: ["-c", "pyproject.toml"]
3232
additional_dependencies: ["bandit[toml]"]
3333

3434
- repo: https://github.com/astral-sh/ruff-pre-commit
35-
rev: v0.8.6
35+
rev: v0.11.0
3636
hooks:
3737
- id: ruff
3838
args: [--fix, --exit-non-zero-on-fix]
@@ -48,7 +48,7 @@ repos:
4848
# args: ["--number"]
4949

5050
- repo: https://github.com/codespell-project/codespell
51-
rev: v2.3.0
51+
rev: v2.4.1
5252
hooks:
5353
- id: codespell
5454
additional_dependencies:

supervision/detection/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def from_azure_analyze_image(
715715
"""
716716
if "error" in azure_result:
717717
raise ValueError(
718-
f'Azure API returned an error {azure_result["error"]["message"]}'
718+
f"Azure API returned an error {azure_result['error']['message']}"
719719
)
720720

721721
xyxy, confidences, class_ids = [], [], []
@@ -1346,9 +1346,9 @@ def with_nms(
13461346
if len(self) == 0:
13471347
return self
13481348

1349-
assert (
1350-
self.confidence is not None
1351-
), "Detections confidence must be given for NMS to be executed."
1349+
assert self.confidence is not None, (
1350+
"Detections confidence must be given for NMS to be executed."
1351+
)
13521352

13531353
if class_agnostic:
13541354
predictions = np.hstack((self.xyxy, self.confidence.reshape(-1, 1)))
@@ -1402,9 +1402,9 @@ def with_nmm(
14021402
if len(self) == 0:
14031403
return self
14041404

1405-
assert (
1406-
self.confidence is not None
1407-
), "Detections confidence must be given for NMM to be executed."
1405+
assert self.confidence is not None, (
1406+
"Detections confidence must be given for NMM to be executed."
1407+
)
14081408

14091409
if class_agnostic:
14101410
predictions = np.hstack((self.xyxy, self.confidence.reshape(-1, 1)))

supervision/detection/overlap_filter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ def box_non_max_merge(
226226
for merge_group in merge_groups:
227227
if len(merge_group) == 0:
228228
raise ValueError(
229-
f"Empty group detected when non-max-merging "
230-
f"detections: {merge_groups}"
229+
f"Empty group detected when non-max-merging detections: {merge_groups}"
231230
)
232231
return merge_groups
233232

supervision/detection/vlm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,18 @@ def from_florence_2(
294294
return xyxy, labels, None, None
295295

296296
if task in ["<REGION_TO_CATEGORY>", "<REGION_TO_DESCRIPTION>"]:
297-
assert isinstance(
298-
result, str
299-
), f"Expected string as <REGION_TO_CATEGORY> result, got {type(result)}"
297+
assert isinstance(result, str), (
298+
f"Expected string as <REGION_TO_CATEGORY> result, got {type(result)}"
299+
)
300300

301301
if result == "No object detected.":
302302
return np.empty((0, 4), dtype=np.float32), np.array([]), None, None
303303

304304
pattern = re.compile(r"<loc_(\d+)><loc_(\d+)><loc_(\d+)><loc_(\d+)>")
305305
match = pattern.search(result)
306-
assert (
307-
match is not None
308-
), f"Expected string to end in location tags, but got {result}"
306+
assert match is not None, (
307+
f"Expected string to end in location tags, but got {result}"
308+
)
309309

310310
w, h = resolution_wh
311311
xyxy = np.array([match.groups()], dtype=np.float32)

supervision/metrics/mean_average_recall.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,7 @@ def plot(self):
670670
ax.set_ylim(0, 1)
671671
ax.set_ylabel("Value", fontweight="bold")
672672
title = (
673-
f"Mean Average Recall, by Object Size"
674-
f"\n(target: {self.metric_target.value})"
673+
f"Mean Average Recall, by Object Size\n(target: {self.metric_target.value})"
675674
)
676675
ax.set_title(title, fontweight="bold")
677676

supervision/validators/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def validate_confidence(confidence: Any, n: int) -> None:
5454

5555

5656
def validate_keypoint_confidence(confidence: Any, n: int, m: int) -> None:
57-
expected_shape = f"({n,m})"
57+
expected_shape = f"({n, m})"
5858
actual_shape = str(getattr(confidence, "shape", None))
5959

6060
if confidence is not None:

test/detection/test_csv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ def assert_csv_equal(file_name, expected_rows):
408408
with open(file_name, mode="r", newline="") as file:
409409
reader = csv.reader(file)
410410
for i, row in enumerate(reader):
411-
assert (
412-
[str(item) for item in expected_rows[i]] == row
413-
), f"Row in CSV didn't match expected output: {row} != {expected_rows[i]}"
411+
assert [str(item) for item in expected_rows[i]] == row, (
412+
f"Row in CSV didn't match expected output: {row} != {expected_rows[i]}"
413+
)
414414

415415
os.remove(file_name)

test/detection/test_json.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ def test_json_sink(
242242
def assert_json_equal(file_name, expected_rows):
243243
with open(file_name, "r") as file:
244244
data = json.load(file)
245-
assert (
246-
data == expected_rows
247-
), f"Data in JSON file didn't match expected output: {data} != {expected_rows}"
245+
assert data == expected_rows, (
246+
f"Data in JSON file didn't match expected output: {data} != {expected_rows}"
247+
)
248248

249249
os.remove(file_name)

test/detection/test_line_counter.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ def test_line_zone_one_detection_default_anchors(
250250
crossed_in_list.append(crossed_in[0])
251251
crossed_out_list.append(crossed_out[0])
252252

253-
assert (
254-
crossed_in_list == expected_crossed_in
255-
), f"expected {expected_crossed_in}, got {crossed_in_list}"
256-
assert (
257-
crossed_out_list == expected_crossed_out
258-
), f"expected {expected_crossed_out}, got {crossed_out_list}"
253+
assert crossed_in_list == expected_crossed_in, (
254+
f"expected {expected_crossed_in}, got {crossed_in_list}"
255+
)
256+
assert crossed_out_list == expected_crossed_out, (
257+
f"expected {expected_crossed_out}, got {crossed_out_list}"
258+
)
259259

260260

261261
@pytest.mark.parametrize(
@@ -415,12 +415,12 @@ def test_line_zone_one_detection(
415415
crossed_in_list.append(crossed_in[0])
416416
crossed_out_list.append(crossed_out[0])
417417

418-
assert (
419-
crossed_in_list == expected_crossed_in
420-
), f"expected {expected_crossed_in}, got {crossed_in_list}"
421-
assert (
422-
crossed_out_list == expected_crossed_out
423-
), f"expected {expected_crossed_out}, got {crossed_out_list}"
418+
assert crossed_in_list == expected_crossed_in, (
419+
f"expected {expected_crossed_in}, got {crossed_in_list}"
420+
)
421+
assert crossed_out_list == expected_crossed_out, (
422+
f"expected {expected_crossed_out}, got {crossed_out_list}"
423+
)
424424

425425

426426
@pytest.mark.parametrize(
@@ -600,12 +600,12 @@ def test_line_zone_one_detection_long_horizon(
600600
crossed_in_list.append(crossed_in[0])
601601
crossed_out_list.append(crossed_out[0])
602602

603-
assert (
604-
crossed_in_list == expected_crossed_in
605-
), f"expected {expected_crossed_in}, got {crossed_in_list}"
606-
assert (
607-
crossed_out_list == expected_crossed_out
608-
), f"expected {expected_crossed_out}, got {crossed_out_list}"
603+
assert crossed_in_list == expected_crossed_in, (
604+
f"expected {expected_crossed_in}, got {crossed_in_list}"
605+
)
606+
assert crossed_out_list == expected_crossed_out, (
607+
f"expected {expected_crossed_out}, got {crossed_out_list}"
608+
)
609609

610610

611611
@pytest.mark.parametrize(

test/detection/test_utils.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,13 @@ def test_process_roboflow_result(
389389
)
390390
for key in result[5]:
391391
if isinstance(result[5][key], np.ndarray):
392-
assert np.array_equal(
393-
result[5][key], expected_result[5][key]
394-
), f"Mismatch in arrays for key {key}"
392+
assert np.array_equal(result[5][key], expected_result[5][key]), (
393+
f"Mismatch in arrays for key {key}"
394+
)
395395
else:
396-
assert (
397-
result[5][key] == expected_result[5][key]
398-
), f"Mismatch in non-array data for key {key}"
396+
assert result[5][key] == expected_result[5][key], (
397+
f"Mismatch in non-array data for key {key}"
398+
)
399399

400400

401401
@pytest.mark.parametrize(
@@ -1042,13 +1042,13 @@ def test_merge_data(
10421042

10431043
for key in result:
10441044
if isinstance(result[key], np.ndarray):
1045-
assert np.array_equal(
1046-
result[key], expected_result[key]
1047-
), f"Mismatch in arrays for key {key}"
1045+
assert np.array_equal(result[key], expected_result[key]), (
1046+
f"Mismatch in arrays for key {key}"
1047+
)
10481048
else:
1049-
assert (
1050-
result[key] == expected_result[key]
1051-
), f"Mismatch in non-array data for key {key}"
1049+
assert result[key] == expected_result[key], (
1050+
f"Mismatch in non-array data for key {key}"
1051+
)
10521052

10531053

10541054
@pytest.mark.parametrize(
@@ -1215,13 +1215,13 @@ def test_get_data_item(
12151215
result = get_data_item(data=data, index=index)
12161216
for key in result:
12171217
if isinstance(result[key], np.ndarray):
1218-
assert np.array_equal(
1219-
result[key], expected_result[key]
1220-
), f"Mismatch in arrays for key {key}"
1218+
assert np.array_equal(result[key], expected_result[key]), (
1219+
f"Mismatch in arrays for key {key}"
1220+
)
12211221
else:
1222-
assert (
1223-
result[key] == expected_result[key]
1224-
), f"Mismatch in non-array data for key {key}"
1222+
assert result[key] == expected_result[key], (
1223+
f"Mismatch in non-array data for key {key}"
1224+
)
12251225

12261226

12271227
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)