mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-30 18:03:07 +03:00
Merge pull request #8844 from radarhere/import
Do not import TYPE_CHECKING
This commit is contained in:
commit
60b5131e9f
|
@ -31,7 +31,7 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from functools import cached_property
|
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 (
|
from . import (
|
||||||
Image,
|
Image,
|
||||||
|
@ -47,6 +47,7 @@ from ._binary import o8
|
||||||
from ._binary import o16le as o16
|
from ._binary import o16le as o16
|
||||||
from ._util import DeferredError
|
from ._util import DeferredError
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import _imaging
|
from . import _imaging
|
||||||
from ._typing import Buffer
|
from ._typing import Buffer
|
||||||
|
|
|
@ -41,14 +41,7 @@ import warnings
|
||||||
from collections.abc import Callable, Iterator, MutableMapping, Sequence
|
from collections.abc import Callable, Iterator, MutableMapping, Sequence
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import (
|
from typing import IO, Any, Literal, Protocol, cast
|
||||||
IO,
|
|
||||||
TYPE_CHECKING,
|
|
||||||
Any,
|
|
||||||
Literal,
|
|
||||||
Protocol,
|
|
||||||
cast,
|
|
||||||
)
|
|
||||||
|
|
||||||
# VERSION was removed in Pillow 6.0.0.
|
# VERSION was removed in Pillow 6.0.0.
|
||||||
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
||||||
|
@ -218,6 +211,7 @@ if hasattr(core, "DEFAULT_STRATEGY"):
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Registries
|
# Registries
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import mmap
|
import mmap
|
||||||
from xml.etree.ElementTree import Element
|
from xml.etree.ElementTree import Element
|
||||||
|
|
|
@ -35,7 +35,7 @@ import math
|
||||||
import struct
|
import struct
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from types import ModuleType
|
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 . import Image, ImageColor
|
||||||
from ._deprecate import deprecate
|
from ._deprecate import deprecate
|
||||||
|
@ -44,6 +44,7 @@ from ._typing import Coords
|
||||||
# experimental access to the outline API
|
# experimental access to the outline API
|
||||||
Outline: Callable[[], Image.core._Outline] = Image.core.outline
|
Outline: Callable[[], Image.core._Outline] = Image.core.outline
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import ImageDraw2, ImageFont
|
from . import ImageDraw2, ImageFont
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,13 @@ import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast
|
from typing import IO, Any, NamedTuple, cast
|
||||||
|
|
||||||
from . import ExifTags, Image
|
from . import ExifTags, Image
|
||||||
from ._deprecate import deprecate
|
from ._deprecate import deprecate
|
||||||
from ._util import DeferredError, is_path
|
from ._util import DeferredError, is_path
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ._typing import StrOrBytesPath
|
from ._typing import StrOrBytesPath
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,9 @@ import abc
|
||||||
import functools
|
import functools
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import TYPE_CHECKING, Any, Callable, cast
|
from typing import Any, Callable, cast
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import _imaging
|
from . import _imaging
|
||||||
from ._typing import NumpyArray
|
from ._typing import NumpyArray
|
||||||
|
|
|
@ -34,12 +34,13 @@ import warnings
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from types import ModuleType
|
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 . import Image, features
|
||||||
from ._typing import StrOrBytesPath
|
from ._typing import StrOrBytesPath
|
||||||
from ._util import DeferredError, is_path
|
from ._util import DeferredError, is_path
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import ImageFile
|
from . import ImageFile
|
||||||
from ._imaging import ImagingFont
|
from ._imaging import ImagingFont
|
||||||
|
|
|
@ -19,10 +19,11 @@ from __future__ import annotations
|
||||||
|
|
||||||
import array
|
import array
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import IO, TYPE_CHECKING
|
from typing import IO
|
||||||
|
|
||||||
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
|
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import Image
|
from . import Image
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,12 @@ from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import TYPE_CHECKING, Any, Callable, Union
|
from typing import Any, Callable, Union
|
||||||
|
|
||||||
from . import Image
|
from . import Image
|
||||||
from ._util import is_path
|
from ._util import is_path
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import PyQt6
|
import PyQt6
|
||||||
import PySide6
|
import PySide6
|
||||||
|
|
|
@ -28,10 +28,11 @@ from __future__ import annotations
|
||||||
|
|
||||||
import tkinter
|
import tkinter
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
|
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ._typing import CapsuleType
|
from ._typing import CapsuleType
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import warnings
|
import warnings
|
||||||
from typing import IO, TYPE_CHECKING, Any
|
from typing import IO, Any
|
||||||
|
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
from ._binary import i16be as i16
|
from ._binary import i16be as i16
|
||||||
|
@ -52,6 +52,7 @@ from ._binary import o16be as o16
|
||||||
from ._deprecate import deprecate
|
from ._deprecate import deprecate
|
||||||
from .JpegPresets import presets
|
from .JpegPresets import presets
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .MpoImagePlugin import MpoImageFile
|
from .MpoImagePlugin import MpoImageFile
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,13 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from typing import IO, TYPE_CHECKING
|
from typing import IO
|
||||||
|
|
||||||
from . import EpsImagePlugin
|
from . import EpsImagePlugin
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Simple PostScript graphics interface.
|
# Simple PostScript graphics interface.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import zlib
|
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
|
# see 7.9.2.2 Text String Type on page 86 and D.3 PDFDocEncoding Character Set
|
||||||
|
@ -251,6 +251,7 @@ class PdfArray(list[Any]):
|
||||||
return b"[ " + b" ".join(pdf_repr(x) for x in self) + b" ]"
|
return b"[ " + b" ".join(pdf_repr(x) for x in self) + b" ]"
|
||||||
|
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
_DictBase = collections.UserDict[Union[str, bytes], Any]
|
_DictBase = collections.UserDict[Union[str, bytes], Any]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -40,7 +40,7 @@ import warnings
|
||||||
import zlib
|
import zlib
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from enum import IntEnum
|
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 . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
|
||||||
from ._binary import i16be as i16
|
from ._binary import i16be as i16
|
||||||
|
@ -50,6 +50,7 @@ from ._binary import o16be as o16
|
||||||
from ._binary import o32be as o32
|
from ._binary import o32be as o32
|
||||||
from ._util import DeferredError
|
from ._util import DeferredError
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from . import _imaging
|
from . import _imaging
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,13 @@ from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
from typing import IO, TYPE_CHECKING, Any, cast
|
from typing import IO, Any, cast
|
||||||
|
|
||||||
from . import Image, ImageFile
|
from . import Image, ImageFile
|
||||||
from ._util import DeferredError
|
from ._util import DeferredError
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
|
|
||||||
|
|
||||||
def isInt(f: Any) -> int:
|
def isInt(f: Any) -> int:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -50,7 +50,7 @@ import warnings
|
||||||
from collections.abc import Iterator, MutableMapping
|
from collections.abc import Iterator, MutableMapping
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from numbers import Number, Rational
|
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 . import ExifTags, Image, ImageFile, ImageOps, ImagePalette, TiffTags
|
||||||
from ._binary import i16be as i16
|
from ._binary import i16be as i16
|
||||||
|
@ -61,6 +61,7 @@ from ._typing import StrOrBytesPath
|
||||||
from ._util import DeferredError, is_path
|
from ._util import DeferredError, is_path
|
||||||
from .TiffTags import TYPES
|
from .TiffTags import TYPES
|
||||||
|
|
||||||
|
TYPE_CHECKING = False
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ._typing import Buffer, IntegralLike
|
from ._typing import Buffer, IntegralLike
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@ from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from collections.abc import Sequence
|
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:
|
if TYPE_CHECKING:
|
||||||
from numbers import _IntegralLike as IntegralLike
|
from numbers import _IntegralLike as IntegralLike
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user