Merge pull request #7780 from python-pillow/pre-commit-ci-update-config

[pre-commit.ci] pre-commit autoupdate
This commit is contained in:
Andrew Murray 2024-02-06 22:26:36 +11:00 committed by GitHub
commit 3e04ca5794
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 34 additions and 28 deletions

View File

@ -6,6 +6,7 @@ This sort of info is missing from GitHub Actions.
Requested here:
https://github.com/actions/virtual-environments/issues/79
"""
from __future__ import annotations
import os

View File

@ -1,17 +1,17 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
rev: 1.7.7
hooks:
- id: bandit
args: [--severity-level=high]
@ -48,12 +48,12 @@ repos:
- id: sphinx-lint
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.5.3
rev: 1.7.0
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
rev: v0.16
hooks:
- id: validate-pyproject

View File

@ -1,6 +1,7 @@
"""
Helper functions.
"""
from __future__ import annotations
import logging

View File

@ -1,4 +1,5 @@
"""Test DdsImagePlugin"""
from __future__ import annotations
from io import BytesIO

View File

@ -9,7 +9,6 @@ from .test_file_libtiff import LibTiffTestCase
class TestFileLibTiffSmall(LibTiffTestCase):
"""The small lena image was failing on open in the libtiff
decoder because the file pointer was set to the wrong place
by a spurious seek. It wasn't failing with the byteio method.

View File

@ -230,9 +230,7 @@ class TestImageGetPixel(AccessTest):
assert im.getpixel([0, 0]) == (20, 20, 70)
@pytest.mark.parametrize("mode", ("I;16", "I;16B"))
@pytest.mark.parametrize(
"expected_color", (2**15 - 1, 2**15, 2**15 + 1, 2**16 - 1)
)
@pytest.mark.parametrize("expected_color", (2**15 - 1, 2**15, 2**15 + 1, 2**16 - 1))
def test_signedness(self, mode, expected_color) -> None:
# see https://github.com/python-pillow/Pillow/issues/452
# pixelaccess is using signed int* instead of uint*

View File

@ -1,6 +1,7 @@
"""
Tests for resize functionality.
"""
from __future__ import annotations
from itertools import permutations

View File

@ -342,9 +342,11 @@ def test_extended_information() -> None:
def truncate_tuple(tuple_or_float):
return tuple(
(
truncate_tuple(val)
if isinstance(val, tuple)
else int(val * power) / power
)
for val in tuple_or_float
)

View File

@ -9,6 +9,7 @@ The contents of this file are hereby released in the public domain (CC0)
Full text of the CC0 license:
https://creativecommons.org/publicdomain/zero/1.0/
"""
from __future__ import annotations
import struct

View File

@ -96,7 +96,7 @@ config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-extras = "tests"
[tool.ruff]
[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
@ -104,25 +104,25 @@ select = [
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
# "LOG", # TODO: enable flake8-logging when it's not in preview anymore
]
extend-ignore = [
ignore = [
"E203", # Whitespace before ':'
"E221", # Multiple spaces before operator
"E226", # Missing whitespace around arithmetic operator
"E241", # Multiple spaces after ','
]
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"Tests/oss-fuzz/fuzz_font.py" = ["I002"]
"Tests/oss-fuzz/fuzz_pillow.py" = ["I002"]
[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["PIL"]
required-imports = ["from __future__ import annotations"]

View File

@ -28,6 +28,7 @@ BLP files come in many different flavours:
- DXT3 compression is used if alpha_encoding == 1.
- DXT5 compression is used if alpha_encoding == 7.
"""
from __future__ import annotations
import os

View File

@ -9,6 +9,7 @@ The contents of this file are hereby released in the public domain (CC0)
Full text of the CC0 license:
https://creativecommons.org/publicdomain/zero/1.0/
"""
from __future__ import annotations
import io

View File

@ -50,9 +50,7 @@ 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

@ -50,6 +50,7 @@ bytes for that mipmap level.
Note: All data is stored in little-Endian (Intel) byte order.
"""
from __future__ import annotations
import struct

View File

@ -641,9 +641,9 @@ def _write_multiple_frames(im, fp, palette):
if encoderinfo.get("optimize") and im_frame.mode != "1":
if "transparency" not in encoderinfo:
try:
encoderinfo[
"transparency"
] = im_frame.palette._new_color_index(im_frame)
encoderinfo["transparency"] = (
im_frame.palette._new_color_index(im_frame)
)
except ValueError:
pass
if "transparency" in encoderinfo:

View File

@ -281,7 +281,6 @@ class ImageCmsProfile:
class ImageCmsTransform(Image.ImagePointHandler):
"""
Transform. This can be used with the procedural API, or with the standard
:py:func:`~PIL.Image.Image.point` method.
@ -369,7 +368,6 @@ def get_display_profile(handle=None):
class PyCMSError(Exception):
"""(pyCMS) Exception class.
This is used for all errors in the pyCMS API."""

View File

@ -62,6 +62,7 @@ Libjpeg ref.:
https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html
"""
from __future__ import annotations
# fmt: off

View File

@ -188,9 +188,9 @@ def _save(im, fp, filename, save_all=False):
x_resolution = y_resolution = im.encoderinfo.get("resolution", 72.0)
info = {
"title": None
if is_appending
else os.path.splitext(os.path.basename(filename))[0],
"title": (
None if is_appending else os.path.splitext(os.path.basename(filename))[0]
),
"author": None,
"subject": None,
"keywords": None,

View File

@ -12,6 +12,7 @@ Use PIL.__version__ for this Pillow version.
;-)
"""
from __future__ import annotations
from . import _version

View File

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