From 115e9a378f116ea2c49cd9e3ec14a9b4cc27b3e4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 5 Oct 2024 20:14:40 +0300 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#290) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/tox-dev/pyproject-fmt: 2.2.3 → 2.2.4](https://github.com/tox-dev/pyproject-fmt/compare/2.2.3...2.2.4) - [github.com/astral-sh/ruff-pre-commit: v0.6.5 → v0.6.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.5...v0.6.8) * fixed SIM910(ruff) and C0103(pylint) Signed-off-by: Alexander Piskun --------- Signed-off-by: Alexander Piskun Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alexander Piskun --- .pre-commit-config.yaml | 4 ++-- pillow_heif/heif.py | 2 +- pillow_heif/misc.py | 10 +++++----- setup.py | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be369a70..b33c3a9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,12 +24,12 @@ repos: - id: black - repo: https://github.com/tox-dev/pyproject-fmt - rev: 2.2.3 + rev: 2.2.4 hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.5 + rev: v0.6.8 hooks: - id: ruff diff --git a/pillow_heif/heif.py b/pillow_heif/heif.py index 19248054..930b846d 100644 --- a/pillow_heif/heif.py +++ b/pillow_heif/heif.py @@ -570,7 +570,7 @@ def _encode_images(images: List[HeifImage], fp, **kwargs) -> None: images_to_save = images_to_save[:1] if not images_to_save: raise ValueError("Cannot write file with no images as HEIF.") - primary_index = _get_primary_index(images_to_save, kwargs.get("primary_index", None)) + primary_index = _get_primary_index(images_to_save, kwargs.get("primary_index")) ctx_write = CtxEncode(compression_format, **kwargs) for i, img in enumerate(images_to_save): img.load() diff --git a/pillow_heif/misc.py b/pillow_heif/misc.py index 3165e5aa..d747030e 100644 --- a/pillow_heif/misc.py +++ b/pillow_heif/misc.py @@ -376,7 +376,7 @@ def __init__(self, compression_format: HeifCompressionFormat, **kwargs): if "subsampling" in kwargs: chroma = SUBSAMPLING_CHROMA_MAP.get(kwargs["subsampling"], None) if chroma is None: - chroma = kwargs.get("chroma", None) + chroma = kwargs.get("chroma") if chroma: enc_params["chroma"] = chroma for key, value in enc_params.items(): @@ -414,11 +414,11 @@ def add_image_ycbcr(self, img: Image.Image, **kwargs) -> None: def _finish_add_image(self, im_out, size: tuple, **kwargs): # set ICC color profile - __icc_profile = kwargs.get("icc_profile", None) + __icc_profile = kwargs.get("icc_profile") if __icc_profile is not None: im_out.set_icc_profile(kwargs.get("icc_profile_type", "prof"), __icc_profile) # set NCLX color profile - if kwargs.get("nclx_profile", None): + if kwargs.get("nclx_profile"): im_out.set_nclx_profile( *[ kwargs["nclx_profile"][i] @@ -438,12 +438,12 @@ def _finish_add_image(self, im_out, size: tuple, **kwargs): image_orientation, ) # adding metadata - exif = kwargs.get("exif", None) + exif = kwargs.get("exif") if exif is not None: if isinstance(exif, Image.Exif): exif = exif.tobytes() im_out.set_exif(self.ctx_write, exif) - xmp = kwargs.get("xmp", None) + xmp = kwargs.get("xmp") if xmp is not None: im_out.set_xmp(self.ctx_write, xmp) for metadata in kwargs.get("metadata", []): diff --git a/setup.py b/setup.py index be7b9b32..b40af67a 100644 --- a/setup.py +++ b/setup.py @@ -275,7 +275,7 @@ def _get_macos_sdk_path(): zip_safe=not PLATFORM_MINGW, ) except RequiredDependencyException as err: - msg = f""" + MSG = f""" The headers or library files could not be found for {err}, a required dependency when compiling Pillow-Heif from source. @@ -284,5 +284,5 @@ def _get_macos_sdk_path(): https://pillow-heif.readthedocs.io/en/latest/installation.html """ - sys.stderr.write(msg) - raise RequiredDependencyException(msg) from None + sys.stderr.write(MSG) + raise RequiredDependencyException(MSG) from None