Adjust code for ruff-format style

This commit is contained in:
Aarni Koskela 2023-10-30 20:14:30 +02:00
parent 4672bd3d50
commit 2b62babd44
18 changed files with 36 additions and 30 deletions

View File

@ -122,9 +122,8 @@ def assert_image_similar(
ave_diff = diff / (a.size[0] * a.size[1])
try:
assert epsilon >= ave_diff, (
(msg or "")
+ f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}"
)
msg or ""
) + f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}"
except Exception as e:
try:
url = upload(a, b)

View File

@ -577,9 +577,7 @@ class TestFileJpeg:
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99
""".split(
None
)
""".split(None)
]
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
""".split(
None
)
""".split(None)
]
# list of qtable lists
assert_image_similar(

View File

@ -313,7 +313,7 @@ class TestFileLibTiff(LibTiffTestCase):
}
def check_tags(
tiffinfo: TiffImagePlugin.ImageFileDirectory_v2 | dict[int, str]
tiffinfo: TiffImagePlugin.ImageFileDirectory_v2 | dict[int, str],
) -> None:
im = hopper()
@ -626,7 +626,6 @@ class TestFileLibTiff(LibTiffTestCase):
# Act
monkeypatch.setattr(TiffImagePlugin, "READ_LIBTIFF", True)
with Image.open(test_file) as im:
# Assert
assert im.size == (128, 128)
assert im.mode == "L"

View File

@ -17,7 +17,10 @@ class TestTTypeFontLeak(PillowLeakTestCase):
draw = ImageDraw.ImageDraw(im)
self._test_leak(
lambda: draw.text(
(0, 0), "some text " * 1024, font=font, fill="black" # ~10k
(0, 0),
"some text " * 1024, # ~10k
font=font,
fill="black",
)
)

View File

@ -812,7 +812,7 @@ def test_rounded_rectangle(
tuple[int, int, int, int]
| tuple[list[int]]
| tuple[tuple[int, int], tuple[int, int]]
)
),
) -> None:
# Arrange
im = Image.new("RGB", (200, 200))

View File

@ -79,7 +79,7 @@ def test_path_constructors(
),
)
def test_invalid_path_constructors(
coords: tuple[str, str] | Sequence[Sequence[int]]
coords: tuple[str, str] | Sequence[Sequence[int]],
) -> None:
# Act
with pytest.raises(ValueError) as e:

View File

@ -56,7 +56,6 @@ if sys.platform == "win32" and sys.version_info >= (3, 14):
)
)
_IMAGING = ("decode", "encode", "map", "display", "outline", "path")
_LIB_IMAGING = (
@ -431,11 +430,11 @@ class pil_build_ext(build_ext):
)
except Exception:
sdk_path = None
if (
not sdk_path
or sdk_path == "/Applications/Xcode.app/Contents/Developer"
xcode_sdk_path = (
"/Applications/Xcode.app/Contents/Developer"
"/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
):
)
if not sdk_path or sdk_path == xcode_sdk_path:
commandlinetools_sdk_path = (
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
)

View File

@ -20,6 +20,7 @@
"""
Parse X Bitmap Distribution Format (BDF)
"""
from __future__ import annotations
from typing import BinaryIO

View File

@ -13,6 +13,7 @@
This module provides constants and clear-text names for various
well-known EXIF tags.
"""
from __future__ import annotations
from enum import IntEnum

View File

@ -50,7 +50,9 @@ class FontFile:
| None
] = [None] * 256
def __getitem__(self, ix: int) -> (
def __getitem__(
self, ix: int
) -> (
tuple[
tuple[int, int],
tuple[int, int, int, int],

View File

@ -25,6 +25,7 @@
implementation is provided for convenience and demonstrational
purposes only.
"""
from __future__ import annotations
from typing import IO

View File

@ -18,6 +18,7 @@ Stuff to translate curve segments to palette values (derived from
the corresponding code in GIMP, written by Federico Mena Quintero.
See the GIMP distribution for more information.)
"""
from __future__ import annotations
from math import log, pi, sin, sqrt

View File

@ -22,6 +22,7 @@
.. seealso:: :py:mod:`PIL.ImageDraw`
"""
from __future__ import annotations
from typing import Any, AnyStr, BinaryIO

View File

@ -698,7 +698,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
def validate_qtables(
qtables: (
str | tuple[list[int], ...] | list[list[int]] | dict[int, list[int]] | None
)
),
) -> list[list[int]] | None:
if qtables is None:
return qtables

View File

@ -113,13 +113,15 @@ class IndirectObjectDef(IndirectReference):
class XrefTable:
def __init__(self) -> None:
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.deleted_entries = {0: 65536} # object ID => generation
# 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 => generation
self.deleted_entries = {0: 65536}
self.reading_finished = False
def __setitem__(self, key: int, value: tuple[int, int]) -> None:

View File

@ -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()`.
To open a WAL file, use the :py:func:`PIL.WalImageFile.open()` function instead.
"""
from __future__ import annotations
from typing import IO

View File

@ -13,6 +13,7 @@
"""Binary input/output support routines."""
from __future__ import annotations
from struct import pack, unpack_from

View File

@ -1,5 +1,4 @@
""" Find compiled module linking to Tcl / Tk libraries
"""
"""Find compiled module linking to Tcl / Tk libraries"""
from __future__ import annotations