From b0542eae1204e4073b4575f49ddfbc2d2afb8339 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 2 Aug 2025 11:15:16 +1000 Subject: [PATCH 1/5] Apply PYI026 --- pyproject.toml | 1 - src/PIL/_imagingcms.pyi | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a9d7ea031..137726a1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -185,7 +185,6 @@ lint.ignore = [ "PT011", # pytest-raises-too-broad "PT012", # pytest-raises-with-multiple-statements "PT017", # pytest-assert-in-except - "PYI026", # flake8-pyi: typing.TypeAlias added in Python 3.10 "PYI034", # flake8-pyi: typing.Self added in Python 3.11 "UP038", # pyupgrade: deprecated rule ] diff --git a/src/PIL/_imagingcms.pyi b/src/PIL/_imagingcms.pyi index ddcf93ab1..4fc0d60ab 100644 --- a/src/PIL/_imagingcms.pyi +++ b/src/PIL/_imagingcms.pyi @@ -1,14 +1,14 @@ import datetime import sys -from typing import Literal, SupportsFloat, TypedDict +from typing import Literal, SupportsFloat, TypeAlias, TypedDict from ._typing import CapsuleType littlecms_version: str | None -_Tuple3f = tuple[float, float, float] -_Tuple2x3f = tuple[_Tuple3f, _Tuple3f] -_Tuple3x3f = tuple[_Tuple3f, _Tuple3f, _Tuple3f] +_Tuple3f: TypeAlias = tuple[float, float, float] +_Tuple2x3f: TypeAlias = tuple[_Tuple3f, _Tuple3f] +_Tuple3x3f: TypeAlias = tuple[_Tuple3f, _Tuple3f, _Tuple3f] class _IccMeasurementCondition(TypedDict): observer: int From ed22b7bc78f4f4bace61a5e825066661f61cbae1 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 2 Aug 2025 11:19:06 +1000 Subject: [PATCH 2/5] Updated match --- Tests/test_imagecms.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 8b5d88ac8..1953458bc 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -208,9 +208,10 @@ def test_exceptions() -> None: ImageCms.getProfileName(None) # type: ignore[arg-type] skip_missing() - # Python <= 3.9: "an integer is required (got type NoneType)" - # Python > 3.9: "'NoneType' object cannot be interpreted as an integer" - with pytest.raises(ImageCms.PyCMSError, match="integer"): + with pytest.raises( + ImageCms.PyCMSError, + match="'NoneType' object cannot be interpreted as an integer", + ): ImageCms.isIntentSupported(SRGB, None, None) # type: ignore[arg-type] From 002c085d49545130020a35fe7e7208eddb6a1a69 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 2 Aug 2025 11:20:26 +1000 Subject: [PATCH 3/5] Moved install into alphabetical order --- .ci/install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index a5c525b56..2178c6646 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -27,6 +27,7 @@ python3 -m pip install --upgrade wheel python3 -m pip install coverage python3 -m pip install defusedxml python3 -m pip install ipython +python3 -m pip install numpy python3 -m pip install olefile python3 -m pip install -U pytest python3 -m pip install -U pytest-cov @@ -36,9 +37,6 @@ python3 -m pip install pyroma # fails on beta 3.14 and PyPy python3 -m pip install --only-binary=:all: pyarrow || true - -python3 -m pip install numpy - # PyQt6 doesn't support PyPy3 if [[ $GHA_PYTHON_VERSION == 3.* ]]; then sudo apt-get -qq install libegl1 libxcb-cursor0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxkbcommon-x11-0 From 83685110fd8d80ab4475957806f7cb5573291fa1 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 2 Aug 2025 13:43:35 +1000 Subject: [PATCH 4/5] Updated CI targets --- docs/installation/platform-support.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/installation/platform-support.rst b/docs/installation/platform-support.rst index f8d6714d0..c7875914e 100644 --- a/docs/installation/platform-support.rst +++ b/docs/installation/platform-support.rst @@ -19,13 +19,13 @@ These platforms are built and tested for every change. +==================================+============================+=====================+ | Alpine | 3.12 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| Amazon Linux 2 | 3.9 | x86-64 | +| Amazon Linux 2 | 3.10 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| Amazon Linux 2023 | 3.9 | x86-64 | +| Amazon Linux 2023 | 3.11 | x86-64 | +----------------------------------+----------------------------+---------------------+ | Arch | 3.13 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| CentOS Stream 9 | 3.9 | x86-64 | +| CentOS Stream 9 | 3.10 | x86-64 | +----------------------------------+----------------------------+---------------------+ | CentOS Stream 10 | 3.12 | x86-64 | +----------------------------------+----------------------------+---------------------+ @@ -42,16 +42,16 @@ These platforms are built and tested for every change. +----------------------------------+----------------------------+---------------------+ | Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | x86-64 | +----------------------------------+----------------------------+---------------------+ -| Ubuntu Linux 24.04 LTS (Noble) | 3.10, 3.11, | x86-64 | -| | 3.12, 3.13, 3.14, PyPy3 | | +| Ubuntu Linux 24.04 LTS (Noble) | 3.10, 3.11, 3.12, 3.13, | x86-64 | +| | 3.14, PyPy3 | | | +----------------------------+---------------------+ | | 3.12 | arm64v8, ppc64le, | | | | s390x | +----------------------------------+----------------------------+---------------------+ | Windows Server 2022 | 3.10 | x86 | | +----------------------------+---------------------+ -| | 3.11, 3.12, 3.13, | x86-64 | -| | 3.14, PyPy3 | | +| | 3.11, 3.12, 3.13, 3.14, | x86-64 | +| | PyPy3 | | | +----------------------------+---------------------+ | | 3.12 (MinGW) | x86-64 | +----------------------------------+----------------------------+---------------------+ From 60fb0fc9388bea906ee083ad1c7e6198f49d4852 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 2 Aug 2025 12:27:44 +1000 Subject: [PATCH 5/5] Rearranged imports --- src/PIL/GifImagePlugin.py | 4 +++- src/PIL/ImageDraw.py | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index 0ca965d38..58c460ef3 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -31,7 +31,7 @@ import os import subprocess from enum import IntEnum from functools import cached_property -from typing import IO, Any, Literal, NamedTuple, cast +from typing import Any, NamedTuple, cast from . import ( Image, @@ -49,6 +49,8 @@ from ._util import DeferredError TYPE_CHECKING = False if TYPE_CHECKING: + from typing import IO, Literal + from . import _imaging from ._typing import Buffer diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index ae092345a..ed46899b4 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -33,22 +33,23 @@ from __future__ import annotations import math import struct -from collections.abc import Callable, Sequence +from collections.abc import Sequence from typing import cast from . import Image, ImageColor -# experimental access to the outline API -Outline: Callable[[], Image.core._Outline] = Image.core.outline - TYPE_CHECKING = False if TYPE_CHECKING: + from collections.abc import Callable from types import ModuleType from typing import Any, AnyStr from . import ImageDraw2, ImageFont from ._typing import Coords +# experimental access to the outline API +Outline: Callable[[], Image.core._Outline] = Image.core.outline + _Ink = float | tuple[int, ...] | str """