mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +03:00
Adjust code for ruff-format style
This commit is contained in:
parent
4672bd3d50
commit
2b62babd44
|
@ -122,9 +122,8 @@ def assert_image_similar(
|
||||||
ave_diff = diff / (a.size[0] * a.size[1])
|
ave_diff = diff / (a.size[0] * a.size[1])
|
||||||
try:
|
try:
|
||||||
assert epsilon >= ave_diff, (
|
assert epsilon >= ave_diff, (
|
||||||
(msg or "")
|
msg or ""
|
||||||
+ f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}"
|
) + f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}"
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
url = upload(a, b)
|
url = upload(a, b)
|
||||||
|
|
|
@ -577,9 +577,7 @@ class TestFileJpeg:
|
||||||
24 35 55 64 81 104 113 92
|
24 35 55 64 81 104 113 92
|
||||||
49 64 78 87 103 121 120 101
|
49 64 78 87 103 121 120 101
|
||||||
72 92 95 98 112 100 103 99
|
72 92 95 98 112 100 103 99
|
||||||
""".split(
|
""".split(None)
|
||||||
None
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
standard_chrominance_qtable = [
|
standard_chrominance_qtable = [
|
||||||
|
@ -593,9 +591,7 @@ class TestFileJpeg:
|
||||||
99 99 99 99 99 99 99 99
|
99 99 99 99 99 99 99 99
|
||||||
99 99 99 99 99 99 99 99
|
99 99 99 99 99 99 99 99
|
||||||
99 99 99 99 99 99 99 99
|
99 99 99 99 99 99 99 99
|
||||||
""".split(
|
""".split(None)
|
||||||
None
|
|
||||||
)
|
|
||||||
]
|
]
|
||||||
# list of qtable lists
|
# list of qtable lists
|
||||||
assert_image_similar(
|
assert_image_similar(
|
||||||
|
|
|
@ -313,7 +313,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_tags(
|
def check_tags(
|
||||||
tiffinfo: TiffImagePlugin.ImageFileDirectory_v2 | dict[int, str]
|
tiffinfo: TiffImagePlugin.ImageFileDirectory_v2 | dict[int, str],
|
||||||
) -> None:
|
) -> None:
|
||||||
im = hopper()
|
im = hopper()
|
||||||
|
|
||||||
|
@ -626,7 +626,6 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
# Act
|
# Act
|
||||||
monkeypatch.setattr(TiffImagePlugin, "READ_LIBTIFF", True)
|
monkeypatch.setattr(TiffImagePlugin, "READ_LIBTIFF", True)
|
||||||
with Image.open(test_file) as im:
|
with Image.open(test_file) as im:
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert im.size == (128, 128)
|
assert im.size == (128, 128)
|
||||||
assert im.mode == "L"
|
assert im.mode == "L"
|
||||||
|
|
|
@ -17,7 +17,10 @@ class TestTTypeFontLeak(PillowLeakTestCase):
|
||||||
draw = ImageDraw.ImageDraw(im)
|
draw = ImageDraw.ImageDraw(im)
|
||||||
self._test_leak(
|
self._test_leak(
|
||||||
lambda: draw.text(
|
lambda: draw.text(
|
||||||
(0, 0), "some text " * 1024, font=font, fill="black" # ~10k
|
(0, 0),
|
||||||
|
"some text " * 1024, # ~10k
|
||||||
|
font=font,
|
||||||
|
fill="black",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -812,7 +812,7 @@ def test_rounded_rectangle(
|
||||||
tuple[int, int, int, int]
|
tuple[int, int, int, int]
|
||||||
| tuple[list[int]]
|
| tuple[list[int]]
|
||||||
| tuple[tuple[int, int], tuple[int, int]]
|
| tuple[tuple[int, int], tuple[int, int]]
|
||||||
)
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
# Arrange
|
# Arrange
|
||||||
im = Image.new("RGB", (200, 200))
|
im = Image.new("RGB", (200, 200))
|
||||||
|
|
|
@ -79,7 +79,7 @@ def test_path_constructors(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_invalid_path_constructors(
|
def test_invalid_path_constructors(
|
||||||
coords: tuple[str, str] | Sequence[Sequence[int]]
|
coords: tuple[str, str] | Sequence[Sequence[int]],
|
||||||
) -> None:
|
) -> None:
|
||||||
# Act
|
# Act
|
||||||
with pytest.raises(ValueError) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
|
|
9
setup.py
9
setup.py
|
@ -56,7 +56,6 @@ if sys.platform == "win32" and sys.version_info >= (3, 14):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
_IMAGING = ("decode", "encode", "map", "display", "outline", "path")
|
_IMAGING = ("decode", "encode", "map", "display", "outline", "path")
|
||||||
|
|
||||||
_LIB_IMAGING = (
|
_LIB_IMAGING = (
|
||||||
|
@ -431,11 +430,11 @@ class pil_build_ext(build_ext):
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
sdk_path = None
|
sdk_path = None
|
||||||
if (
|
xcode_sdk_path = (
|
||||||
not sdk_path
|
"/Applications/Xcode.app/Contents/Developer"
|
||||||
or sdk_path == "/Applications/Xcode.app/Contents/Developer"
|
|
||||||
"/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
"/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
||||||
):
|
)
|
||||||
|
if not sdk_path or sdk_path == xcode_sdk_path:
|
||||||
commandlinetools_sdk_path = (
|
commandlinetools_sdk_path = (
|
||||||
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
|
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"""
|
"""
|
||||||
Parse X Bitmap Distribution Format (BDF)
|
Parse X Bitmap Distribution Format (BDF)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import BinaryIO
|
from typing import BinaryIO
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
This module provides constants and clear-text names for various
|
This module provides constants and clear-text names for various
|
||||||
well-known EXIF tags.
|
well-known EXIF tags.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
|
|
@ -50,7 +50,9 @@ class FontFile:
|
||||||
| None
|
| None
|
||||||
] = [None] * 256
|
] = [None] * 256
|
||||||
|
|
||||||
def __getitem__(self, ix: int) -> (
|
def __getitem__(
|
||||||
|
self, ix: int
|
||||||
|
) -> (
|
||||||
tuple[
|
tuple[
|
||||||
tuple[int, int],
|
tuple[int, int],
|
||||||
tuple[int, int, int, int],
|
tuple[int, int, int, int],
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
implementation is provided for convenience and demonstrational
|
implementation is provided for convenience and demonstrational
|
||||||
purposes only.
|
purposes only.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
|
@ -18,6 +18,7 @@ Stuff to translate curve segments to palette values (derived from
|
||||||
the corresponding code in GIMP, written by Federico Mena Quintero.
|
the corresponding code in GIMP, written by Federico Mena Quintero.
|
||||||
See the GIMP distribution for more information.)
|
See the GIMP distribution for more information.)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from math import log, pi, sin, sqrt
|
from math import log, pi, sin, sqrt
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
.. seealso:: :py:mod:`PIL.ImageDraw`
|
.. seealso:: :py:mod:`PIL.ImageDraw`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, AnyStr, BinaryIO
|
from typing import Any, AnyStr, BinaryIO
|
||||||
|
|
|
@ -698,7 +698,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
def validate_qtables(
|
def validate_qtables(
|
||||||
qtables: (
|
qtables: (
|
||||||
str | tuple[list[int], ...] | list[list[int]] | dict[int, list[int]] | None
|
str | tuple[list[int], ...] | list[list[int]] | dict[int, list[int]] | None
|
||||||
)
|
),
|
||||||
) -> list[list[int]] | None:
|
) -> list[list[int]] | None:
|
||||||
if qtables is None:
|
if qtables is None:
|
||||||
return qtables
|
return qtables
|
||||||
|
|
|
@ -113,13 +113,15 @@ class IndirectObjectDef(IndirectReference):
|
||||||
|
|
||||||
class XrefTable:
|
class XrefTable:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.existing_entries: dict[int, tuple[int, int]] = (
|
# object ID => (offset, generation)
|
||||||
{}
|
self.existing_entries: dict[int, tuple[int, int]] = {}
|
||||||
) # object ID => (offset, generation)
|
|
||||||
self.new_entries: dict[int, tuple[int, int]] = (
|
# object ID => (offset, generation)
|
||||||
{}
|
self.new_entries: dict[int, tuple[int, int]] = {}
|
||||||
) # object ID => (offset, generation)
|
|
||||||
self.deleted_entries = {0: 65536} # object ID => generation
|
# object ID => generation
|
||||||
|
self.deleted_entries = {0: 65536}
|
||||||
|
|
||||||
self.reading_finished = False
|
self.reading_finished = False
|
||||||
|
|
||||||
def __setitem__(self, key: int, value: tuple[int, int]) -> None:
|
def __setitem__(self, key: int, value: tuple[int, int]) -> None:
|
||||||
|
|
|
@ -22,6 +22,7 @@ and has been tested with a few sample files found using google.
|
||||||
is not registered for use with :py:func:`PIL.Image.open()`.
|
is not registered for use with :py:func:`PIL.Image.open()`.
|
||||||
To open a WAL file, use the :py:func:`PIL.WalImageFile.open()` function instead.
|
To open a WAL file, use the :py:func:`PIL.WalImageFile.open()` function instead.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
"""Binary input/output support routines."""
|
"""Binary input/output support routines."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from struct import pack, unpack_from
|
from struct import pack, unpack_from
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
""" Find compiled module linking to Tcl / Tk libraries
|
"""Find compiled module linking to Tcl / Tk libraries"""
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user