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 #157

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .github/transform_to-pi_heif.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Script to transform the project to `pi-heif` in place. Should be used only with GA Actions."""

import os
import pathlib

DEV_NAME_ADD = "" # This is only for debugging purposes of this script.

Expand All @@ -22,9 +23,8 @@
files_list += [os.path.join(dir_name, x)]

for file_name in files_list:
with open(file_name) as file:
data = file.read()
modified_data = data.replace("pillow_heif", "pi_heif")
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)
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ repos:
- id: black

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.2.0
rev: 1.3.0
hooks:
- id: pyproject-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.1
rev: v0.1.3
hooks:
- id: ruff

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
def get_version():
"""Returns version of the project."""
version_file = "pillow_heif/_version.py"
with open(version_file, encoding="utf-8") as f:
exec(compile(f.read(), version_file, "exec")) # pylint: disable=exec-used
exec(compile(Path(version_file).read_text(encoding="utf-8"), version_file, "exec")) # pylint: disable=exec-used
return locals()["__version__"]


Expand Down
9 changes: 3 additions & 6 deletions tests/leaks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def perform_open_save(iterations, image_path):
def test_open_save_objects_leaks(image):
from pympler import summary, tracker

with open(image, mode="rb") as file:
image_file_data = BytesIO(file.read())
image_file_data = BytesIO(Path(image).read_bytes())
perform_open_save(1, image_file_data)
gc.collect()
_summary1 = tracker.SummaryTracker().create_summary()
Expand Down Expand Up @@ -68,8 +67,7 @@ def test_open_to_numpy_mem_leaks():
import numpy as np

mem_limit = None
with open(Path("images/heif/L_10__29x100.heif"), mode="rb") as file:
image_file_data = BytesIO(file.read())
image_file_data = BytesIO(Path("images/heif/L_10__29x100.heif").read_bytes())
for i in range(1000):
heif_file = pillow_heif.open_heif(image_file_data, convert_hdr_to_8bit=False)
_array = np.asarray(heif_file[0]) # noqa
Expand Down Expand Up @@ -121,8 +119,7 @@ def test_metadata_leaks():
@pytest.mark.skipif(machine().find("x86_64") == -1, reason="run only on x86_64")
def test_pillow_plugin_leaks():
mem_limit = None
with open(Path("images/heif/zPug_3.heic"), mode="rb") as file:
image_file_data = BytesIO(file.read())
image_file_data = BytesIO(Path("images/heif/zPug_3.heic").read_bytes())
for i in range(1000):
im = Image.open(image_file_data)
for frame in ImageSequence.Iterator(im):
Expand Down