diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 232cbb16c..f0913e7a9 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -802,14 +802,10 @@ def test_rectangle_translucent_outline(bbox: Coords) -> None: @pytest.mark.parametrize( "xy", - [(10, 20, 190, 180), ([10, 20], [190, 180]), ((10, 20), (190, 180))], + [(10, 20, 190, 180), ((10, 20), (190, 180))], ) def test_rounded_rectangle( - xy: ( - tuple[int, int, int, int] - | tuple[list[int]] - | tuple[tuple[int, int], tuple[int, int]] - ), + xy: tuple[int, int, int, int] | tuple[tuple[int, int], tuple[int, int]], ) -> None: # Arrange im = Image.new("RGB", (200, 200)) diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index c4ebc5931..e7213cb0a 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -244,12 +244,12 @@ class ImageDraw: if ink is not None: self.draw.draw_lines(xy, ink, width) if joint == "curve" and width > 4: - points: Sequence[Sequence[float]] - if isinstance(xy[0], (list, tuple)): - points = cast(Sequence[Sequence[float]], xy) + points: Sequence[tuple[float, ...]] + if isinstance(xy[0], tuple): + points = cast(Sequence[tuple[float, ...]], xy) else: points = [ - cast(Sequence[float], tuple(xy[i : i + 2])) + tuple(cast(Sequence[float], xy)[i : i + 2]) for i in range(0, len(xy), 2) ] for i in range(1, len(points) - 1): diff --git a/src/PIL/_typing.py b/src/PIL/_typing.py index 34a9a81e1..2f0e4a1f9 100644 --- a/src/PIL/_typing.py +++ b/src/PIL/_typing.py @@ -37,7 +37,7 @@ else: return bool -Coords = Union[Sequence[float], Sequence[Sequence[float]]] +Coords = Union[Sequence[float], Sequence[tuple[float, ...]]] _T_co = TypeVar("_T_co", covariant=True)