Skip to content

Commit 4b258be

Browse files
authored
Merge pull request #8151 from radarhere/type_hint_imagedraw
2 parents 96b1cab + 9f79e5d commit 4b258be

File tree

3 files changed

+187
-86
lines changed

3 files changed

+187
-86
lines changed

Tests/test_imagedraw.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ def test_shape1() -> None:
448448
x3, y3 = 95, 5
449449

450450
# Act
451+
assert ImageDraw.Outline is not None
451452
s = ImageDraw.Outline()
452453
s.move(x0, y0)
453454
s.curve(x1, y1, x2, y2, x3, y3)
@@ -469,6 +470,7 @@ def test_shape2() -> None:
469470
x3, y3 = 5, 95
470471

471472
# Act
473+
assert ImageDraw.Outline is not None
472474
s = ImageDraw.Outline()
473475
s.move(x0, y0)
474476
s.curve(x1, y1, x2, y2, x3, y3)
@@ -487,6 +489,7 @@ def test_transform() -> None:
487489
draw = ImageDraw.Draw(im)
488490

489491
# Act
492+
assert ImageDraw.Outline is not None
490493
s = ImageDraw.Outline()
491494
s.line(0, 0)
492495
s.transform((0, 0, 0, 0, 0, 0))
@@ -913,7 +916,12 @@ def test_rounded_rectangle_translucent(
913916
def test_floodfill(bbox: Coords) -> None:
914917
red = ImageColor.getrgb("red")
915918

916-
for mode, value in [("L", 1), ("RGBA", (255, 0, 0, 0)), ("RGB", red)]:
919+
mode_values: list[tuple[str, int | tuple[int, ...]]] = [
920+
("L", 1),
921+
("RGBA", (255, 0, 0, 0)),
922+
("RGB", red),
923+
]
924+
for mode, value in mode_values:
917925
# Arrange
918926
im = Image.new(mode, (W, H))
919927
draw = ImageDraw.Draw(im)
@@ -1429,6 +1437,7 @@ def test_same_color_outline(bbox: Coords) -> None:
14291437
x2, y2 = 95, 50
14301438
x3, y3 = 95, 5
14311439

1440+
assert ImageDraw.Outline is not None
14321441
s = ImageDraw.Outline()
14331442
s.move(x0, y0)
14341443
s.curve(x1, y1, x2, y2, x3, y3)
@@ -1467,7 +1476,7 @@ def test_same_color_outline(bbox: Coords) -> None:
14671476
(4, "square", {}),
14681477
(8, "regular_octagon", {}),
14691478
(4, "square_rotate_45", {"rotation": 45}),
1470-
(3, "triangle_width", {"width": 5, "outline": "yellow"}),
1479+
(3, "triangle_width", {"outline": "yellow", "width": 5}),
14711480
],
14721481
)
14731482
def test_draw_regular_polygon(
@@ -1477,7 +1486,10 @@ def test_draw_regular_polygon(
14771486
filename = f"Tests/images/imagedraw_{polygon_name}.png"
14781487
draw = ImageDraw.Draw(im)
14791488
bounding_circle = ((W // 2, H // 2), 25)
1480-
draw.regular_polygon(bounding_circle, n_sides, fill="red", **args)
1489+
rotation = int(args.get("rotation", 0))
1490+
outline = args.get("outline")
1491+
width = int(args.get("width", 1))
1492+
draw.regular_polygon(bounding_circle, n_sides, rotation, "red", outline, width)
14811493
assert_image_equal_tofile(im, filename)
14821494

14831495

@@ -1630,6 +1642,6 @@ def test_incorrectly_ordered_coordinates(xy: tuple[int, int, int, int]) -> None:
16301642
draw.rounded_rectangle(xy)
16311643

16321644

1633-
def test_getdraw():
1645+
def test_getdraw() -> None:
16341646
with pytest.warns(DeprecationWarning):
16351647
ImageDraw.getdraw(None, [])

0 commit comments

Comments
 (0)