Skip to content

Commit e3b5d3a

Browse files
Fix lint issues (#9218)
1 parent bddc4d8 commit e3b5d3a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

test/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def test_draw_segmentation_masks_errors(device):
409409
utils.draw_segmentation_masks(image=img, masks=masks_bad_shape)
410410
with pytest.raises(ValueError, match="Number of colors must be equal or larger than the number of objects"):
411411
utils.draw_segmentation_masks(image=img, masks=masks, colors=[])
412-
with pytest.raises(ValueError, match="`colors` must be a tuple or a string, or a list thereof"):
412+
with pytest.raises(ValueError, match="colors must be a tuple or a string, or a list thereof"):
413413
bad_colors = np.array(["red", "blue"]) # should be a list
414414
utils.draw_segmentation_masks(image=img, masks=masks, colors=bad_colors)
415415
with pytest.raises(ValueError, match="If passed as tuple, colors should be an RGB triplet"):

torchvision/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,14 @@ def draw_bounding_boxes(
359359
f"Number of boxes ({num_boxes}) and labels ({len(labels)}) mismatch. Please specify labels for each box."
360360
)
361361

362-
colors = _parse_colors(colors, num_objects=num_boxes)
362+
colors = _parse_colors(colors, num_objects=num_boxes) # type: ignore[assignment]
363363
if label_colors or fill_labels:
364364
label_colors = _parse_colors(label_colors if label_colors else "black", num_objects=num_boxes) # type: ignore[assignment]
365365
else:
366366
label_colors = colors.copy() # type: ignore[assignment]
367367

368368
if fill_labels and label_background_colors:
369-
label_background_colors = _parse_colors(label_background_colors, num_objects=num_boxes)
369+
label_background_colors = _parse_colors(label_background_colors, num_objects=num_boxes) # type: ignore[assignment]
370370
else:
371371
label_background_colors = colors.copy() # type: ignore[assignment]
372372

@@ -404,7 +404,7 @@ def draw_bounding_boxes(
404404
if fill_labels:
405405
left, top, right, bottom = draw.textbbox((bbox[0] + margin, bbox[1] + margin), label, font=txt_font)
406406
draw.rectangle(
407-
(left - box_margin, top - box_margin, right + box_margin, bottom + box_margin), fill=label_bg_color
407+
(left - box_margin, top - box_margin, right + box_margin, bottom + box_margin), fill=label_bg_color # type: ignore[arg-type]
408408
)
409409
draw.text((bbox[0] + margin, bbox[1] + margin), label, fill=label_color, font=txt_font) # type: ignore[arg-type]
410410

0 commit comments

Comments
 (0)