From e9b6412e2f81138bf97f1ae27bc051a476afe424 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Tue, 16 Apr 2024 21:13:28 +0300 Subject: [PATCH] fixed linter warnings Signed-off-by: Alexander Piskun --- .github/transform_to-pi_heif.py | 3 +-- pillow_heif/misc.py | 2 +- pyproject.toml | 10 +++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/transform_to-pi_heif.py b/.github/transform_to-pi_heif.py index e2dfc44f..fa60594d 100644 --- a/.github/transform_to-pi_heif.py +++ b/.github/transform_to-pi_heif.py @@ -26,8 +26,7 @@ data = pathlib.Path(file_name).read_text(encoding="utf-8") modified_data = data.replace("pillow_heif", "pi_heif") if modified_data != data: - with open(file_name + DEV_NAME_ADD, "w") as file: - file.write(modified_data) + pathlib.Path(file_name + DEV_NAME_ADD).write_text(modified_data) os.rename("pillow_heif/_pillow_heif.c", "pillow_heif/_pi_heif.c") os.rename("pillow_heif", "pi_heif") diff --git a/pillow_heif/misc.py b/pillow_heif/misc.py index a92462d3..33a674ad 100644 --- a/pillow_heif/misc.py +++ b/pillow_heif/misc.py @@ -173,7 +173,7 @@ def _get_orientation(info: dict, reset: bool = False) -> Optional[int]: except Exception: # noqa # pylint: disable=broad-except pass xmp_orientation = _get_orientation_xmp(info, original_orientation, reset=reset) - return xmp_orientation if xmp_orientation else original_orientation + return xmp_orientation or original_orientation def get_file_mimetype(fp) -> str: diff --git a/pyproject.toml b/pyproject.toml index 14d21562..80d4766e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,21 +49,21 @@ preview = true line-length = 120 preview = true target-version = "py38" -select = ["A", "B", "C", "D", "E", "F", "FURB", "G", "I", "S", "SIM", "PERF", "PIE", "Q", "RET", "RUF", "UP" , "W"] -extend-ignore = ["D107", "D105", "D203", "D213", "D401", "E203", "I001", "RUF100"] +lint.select = ["A", "B", "C", "D", "E", "F", "FURB", "G", "I", "S", "SIM", "PERF", "PIE", "Q", "RET", "RUF", "UP" , "W"] +lint.extend-ignore = ["D107", "D105", "D203", "D213", "D401", "E203", "I001", "RUF100"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "pillow_heif/__init__.py" = ["F401"] "setup.py" = ["S"] -[tool.ruff.extend-per-file-ignores] +[tool.ruff.lint.extend-per-file-ignores] "benchmarks/**/*.py" = ["D", "S404", "S603"] "docs/**/*.py" = ["D"] "examples/**/*.py" = ["D", "PERF"] "libheif/**/*.py" = ["D", "PERF", "S"] "tests/**/*.py" = ["B009", "D", "E402", "PERF", "S", "UP"] -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] max-complexity = 16 [tool.isort]