Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#157)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/tox-dev/pyproject-fmt: 1.2.0 → 1.3.0](tox-dev/pyproject-fmt@1.2.0...1.3.0)
- [github.com/astral-sh/ruff-pre-commit: v0.1.1 → v0.1.3](astral-sh/ruff-pre-commit@v0.1.1...v0.1.3)

* fixed new `ruff` warnings

Signed-off-by: Alexander Piskun <[email protected]>

---------

Signed-off-by: Alexander Piskun <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alexander Piskun <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and bigcat88 authored Oct 31, 2023
1 parent ff4da71 commit bd32c73
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
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

0 comments on commit bd32c73

Please sign in to comment.