Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate and fix deprecations #7780

Merged
merged 5 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .github/workflows/system-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Requested here:
https://github.com/actions/virtual-environments/issues/79
"""

from __future__ import annotations

import os
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions.
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_dds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test DdsImagePlugin"""

from __future__ import annotations

from io import BytesIO
Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_libtiff_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


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.
Expand Down
4 changes: 1 addition & 3 deletions Tests/test_image_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ def test_list(self) -> None:
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*
Expand Down
1 change: 1 addition & 0 deletions Tests/test_image_resize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for resize functionality.
"""

from __future__ import annotations

from itertools import permutations
Expand Down
8 changes: 5 additions & 3 deletions Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ def assert_truncated_tuple_equal(tup1, tup2, digits: int = 10) -> None:

def truncate_tuple(tuple_or_float):
return tuple(
truncate_tuple(val)
if isinstance(val, tuple)
else int(val * power) / power
(
truncate_tuple(val)
if isinstance(val, tuple)
else int(val * power) / power
)
for val in tuple_or_float
)

Expand Down
1 change: 1 addition & 0 deletions docs/example/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Full text of the CC0 license:
https://creativecommons.org/publicdomain/zero/1.0/
"""

from __future__ import annotations

import struct
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@ 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
"EM", # flake8-errmsg
"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 = [
"E203", # Whitespace before ':'
Expand All @@ -118,11 +118,11 @@ extend-ignore = [
"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"]

Expand Down
1 change: 1 addition & 0 deletions src/PIL/BlpImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- DXT3 compression is used if alpha_encoding == 1.
- DXT5 compression is used if alpha_encoding == 7.
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Full text of the CC0 license:
https://creativecommons.org/publicdomain/zero/1.0/
"""

from __future__ import annotations

import io
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/FontFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def __init__(self) -> None:
| None
] = [None] * 256

def __getitem__(
self, ix: int
) -> (
def __getitem__(self, ix: int) -> (
tuple[
tuple[int, int],
tuple[int, int, int, int],
Expand Down
1 change: 1 addition & 0 deletions src/PIL/FtexImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

Note: All data is stored in little-Endian (Intel) byte order.
"""

from __future__ import annotations

import struct
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/GifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions src/PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ def tobytes(self):


class ImageCmsTransform(Image.ImagePointHandler):

"""
Transform. This can be used with the procedural API, or with the standard
:py:func:`~PIL.Image.Image.point` method.
Expand Down Expand Up @@ -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."""

Expand Down
1 change: 1 addition & 0 deletions src/PIL/JpegPresets.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
https://web.archive.org/web/20120328125543/http://www.jpegcameras.com/libjpeg/libjpeg-3.html

"""

from __future__ import annotations

# fmt: off
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/PdfImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/PIL/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

;-)
"""

from __future__ import annotations

from . import _version
Expand Down
1 change: 1 addition & 0 deletions src/PIL/_tkinter_finder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Find compiled module linking to Tcl / Tk libraries
"""

from __future__ import annotations

import sys
Expand Down
Loading