Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/PIL/GifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import subprocess
from enum import IntEnum
from functools import cached_property
from typing import IO, TYPE_CHECKING, Any, Literal, NamedTuple, Union
from typing import IO, Any, Literal, NamedTuple, Union

from . import (
Image,
Expand All @@ -47,6 +47,7 @@
from ._binary import o16le as o16
from ._util import DeferredError

TYPE_CHECKING = False
if TYPE_CHECKING:
from . import _imaging
from ._typing import Buffer
Expand Down
10 changes: 2 additions & 8 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@
from collections.abc import Callable, Iterator, MutableMapping, Sequence
from enum import IntEnum
from types import ModuleType
from typing import (
IO,
TYPE_CHECKING,
Any,
Literal,
Protocol,
cast,
)
from typing import IO, Any, Literal, Protocol, cast

# VERSION was removed in Pillow 6.0.0.
# PILLOW_VERSION was removed in Pillow 9.0.0.
Expand Down Expand Up @@ -218,6 +211,7 @@ class Quantize(IntEnum):
# --------------------------------------------------------------------
# Registries

TYPE_CHECKING = False
if TYPE_CHECKING:
import mmap
from xml.etree.ElementTree import Element
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageDraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import struct
from collections.abc import Sequence
from types import ModuleType
from typing import TYPE_CHECKING, Any, AnyStr, Callable, Union, cast
from typing import Any, AnyStr, Callable, Union, cast

from . import Image, ImageColor
from ._deprecate import deprecate
Expand All @@ -44,6 +44,7 @@
# experimental access to the outline API
Outline: Callable[[], Image.core._Outline] = Image.core.outline

TYPE_CHECKING = False
if TYPE_CHECKING:
from . import ImageDraw2, ImageFont

Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
import logging
import os
import struct
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast
from typing import IO, Any, NamedTuple, cast

from . import ExifTags, Image
from ._deprecate import deprecate
from ._util import DeferredError, is_path

TYPE_CHECKING = False
if TYPE_CHECKING:
from ._typing import StrOrBytesPath

Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import functools
from collections.abc import Sequence
from types import ModuleType
from typing import TYPE_CHECKING, Any, Callable, cast
from typing import Any, Callable, cast

TYPE_CHECKING = False
if TYPE_CHECKING:
from . import _imaging
from ._typing import NumpyArray
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
from enum import IntEnum
from io import BytesIO
from types import ModuleType
from typing import IO, TYPE_CHECKING, Any, BinaryIO, TypedDict, cast
from typing import IO, Any, BinaryIO, TypedDict, cast

from . import Image, features
from ._typing import StrOrBytesPath
from ._util import DeferredError, is_path

TYPE_CHECKING = False
if TYPE_CHECKING:
from . import ImageFile
from ._imaging import ImagingFont
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImagePalette.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

import array
from collections.abc import Sequence
from typing import IO, TYPE_CHECKING
from typing import IO

from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile

TYPE_CHECKING = False
if TYPE_CHECKING:
from . import Image

Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

import sys
from io import BytesIO
from typing import TYPE_CHECKING, Any, Callable, Union
from typing import Any, Callable, Union

from . import Image
from ._util import is_path

TYPE_CHECKING = False
if TYPE_CHECKING:
import PyQt6
import PySide6
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/ImageTk.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@

import tkinter
from io import BytesIO
from typing import TYPE_CHECKING, Any
from typing import Any

from . import Image, ImageFile

TYPE_CHECKING = False
if TYPE_CHECKING:
from ._typing import CapsuleType

Expand Down
3 changes: 2 additions & 1 deletion src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import sys
import tempfile
import warnings
from typing import IO, TYPE_CHECKING, Any
from typing import IO, Any

from . import Image, ImageFile
from ._binary import i16be as i16
Expand All @@ -52,6 +52,7 @@
from ._deprecate import deprecate
from .JpegPresets import presets

TYPE_CHECKING = False
if TYPE_CHECKING:
from .MpoImagePlugin import MpoImageFile

Expand Down
5 changes: 4 additions & 1 deletion src/PIL/PSDraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
from __future__ import annotations

import sys
from typing import IO, TYPE_CHECKING
from typing import IO

from . import EpsImagePlugin

TYPE_CHECKING = False


##
# Simple PostScript graphics interface.

Expand Down
3 changes: 2 additions & 1 deletion src/PIL/PdfParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
import time
import zlib
from typing import IO, TYPE_CHECKING, Any, NamedTuple, Union
from typing import IO, Any, NamedTuple, Union


# see 7.9.2.2 Text String Type on page 86 and D.3 PDFDocEncoding Character Set
Expand Down Expand Up @@ -251,6 +251,7 @@ def __bytes__(self) -> bytes:
return b"[ " + b" ".join(pdf_repr(x) for x in self) + b" ]"


TYPE_CHECKING = False
if TYPE_CHECKING:
_DictBase = collections.UserDict[Union[str, bytes], Any]
else:
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import zlib
from collections.abc import Callable
from enum import IntEnum
from typing import IO, TYPE_CHECKING, Any, NamedTuple, NoReturn, cast
from typing import IO, Any, NamedTuple, NoReturn, cast

from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16be as i16
Expand All @@ -50,6 +50,7 @@
from ._binary import o32be as o32
from ._util import DeferredError

TYPE_CHECKING = False
if TYPE_CHECKING:
from . import _imaging

Expand Down
4 changes: 3 additions & 1 deletion src/PIL/SpiderImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
import os
import struct
import sys
from typing import IO, TYPE_CHECKING, Any, cast
from typing import IO, Any, cast

from . import Image, ImageFile
from ._util import DeferredError

TYPE_CHECKING = False


def isInt(f: Any) -> int:
try:
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from collections.abc import Iterator, MutableMapping
from fractions import Fraction
from numbers import Number, Rational
from typing import IO, TYPE_CHECKING, Any, Callable, NoReturn, cast
from typing import IO, Any, Callable, NoReturn, cast

from . import ExifTags, Image, ImageFile, ImageOps, ImagePalette, TiffTags
from ._binary import i16be as i16
Expand All @@ -61,6 +61,7 @@
from ._util import DeferredError, is_path
from .TiffTags import TYPES

TYPE_CHECKING = False
if TYPE_CHECKING:
from ._typing import Buffer, IntegralLike

Expand Down
3 changes: 2 additions & 1 deletion src/PIL/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import os
import sys
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Protocol, TypeVar, Union
from typing import Any, Protocol, TypeVar, Union

TYPE_CHECKING = False
if TYPE_CHECKING:
from numbers import _IntegralLike as IntegralLike

Expand Down
Loading