Skip to content

Commit

Permalink
Merge pull request #6928 from python-pillow/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
mergify[bot] authored Feb 6, 2023
2 parents 569751e + 24183d6 commit 55d6cf5
Show file tree
Hide file tree
Showing 112 changed files with 9 additions and 299 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
args: [--target-version=py37]
Expand Down
1 change: 0 additions & 1 deletion Tests/check_fli_overflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def test_fli_overflow():

# this should not crash with a malloc error or access violation
with Image.open(TEST_FILE) as im:
im.load()
1 change: 0 additions & 1 deletion Tests/check_png_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def test_ignore_dos_text():


def test_dos_text():

try:
im = Image.open(TEST_FILE)
im.load()
Expand Down
1 change: 0 additions & 1 deletion Tests/test_bmp_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_bad():
"""These shouldn't crash/dos, but they shouldn't return anything
either"""
for f in get_files("b"):

# Assert that there is no unclosed file warning
with warnings.catch_warnings():
try:
Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_bmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def test_rgba_bitfields():
# This test image has been manually hexedited
# to change the bitfield compression in the header from XBGR to RGBA
with Image.open("Tests/images/rgb32bf-rgba.bmp") as im:

# So before the comparing the image, swap the channels
b, g, r = im.split()[1:]
im = Image.merge("RGB", (r, g, b))
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_file_bufrstub.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def test_open():
# Act
with Image.open(TEST_FILE) as im:

# Assert
assert im.format == "BUFR"

Expand All @@ -31,7 +30,6 @@ def test_invalid_file():
def test_load():
# Arrange
with Image.open(TEST_FILE) as im:

# Act / Assert: stub cannot load without an implemented handler
with pytest.raises(OSError):
im.load()
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_file_dcx.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def test_sanity():

# Act
with Image.open(TEST_FILE) as im:

# Assert
assert im.size == (128, 128)
assert isinstance(im, DcxImagePlugin.DcxImageFile)
Expand Down Expand Up @@ -54,7 +53,6 @@ def test_invalid_file():
def test_tell():
# Arrange
with Image.open(TEST_FILE) as im:

# Act
frame = im.tell()

Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_eps.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def test_invalid_file():
@pytest.mark.skipif(not HAS_GHOSTSCRIPT, reason="Ghostscript not available")
def test_cmyk():
with Image.open("Tests/images/pil_sample_cmyk.eps") as cmyk_image:

assert cmyk_image.mode == "CMYK"
assert cmyk_image.size == (100, 100)
assert cmyk_image.format == "EPS"
Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
def test_open():
# Act
with Image.open(TEST_FILE) as im:

# Assert
assert im.format == "FITS"
assert im.size == (128, 128)
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_file_fli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def test_context_manager():
def test_tell():
# Arrange
with Image.open(static_test_file) as im:

# Act
frame = im.tell()

Expand Down Expand Up @@ -110,7 +109,6 @@ def test_eoferror():

def test_seek_tell():
with Image.open(animated_test_file) as im:

layer_number = im.tell()
assert layer_number == 0

Expand Down
13 changes: 1 addition & 12 deletions Tests/test_file_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_optimize_if_palette_can_be_reduced_by_half():
im = im.resize((591, 443))
im_rgb = im.convert("RGB")

for (optimize, colors) in ((False, 256), (True, 8)):
for optimize, colors in ((False, 256), (True, 8)):
out = BytesIO()
im_rgb.save(out, "GIF", optimize=optimize)
with Image.open(out) as reloaded:
Expand All @@ -221,7 +221,6 @@ def test_roundtrip(tmp_path):
im = hopper()
im.save(out)
with Image.open(out) as reread:

assert_image_similar(reread.convert("RGB"), im, 50)


Expand All @@ -232,7 +231,6 @@ def test_roundtrip2(tmp_path):
im2 = im.copy()
im2.save(out)
with Image.open(out) as reread:

assert_image_similar(reread.convert("RGB"), hopper(), 50)


Expand All @@ -242,7 +240,6 @@ def test_roundtrip_save_all(tmp_path):
im = hopper()
im.save(out, save_all=True)
with Image.open(out) as reread:

assert_image_similar(reread.convert("RGB"), im, 50)

# Multiframe image
Expand Down Expand Up @@ -284,13 +281,11 @@ def test_headers_saving_for_animated_gifs(tmp_path):
important_headers = ["background", "version", "duration", "loop"]
# Multiframe image
with Image.open("Tests/images/dispose_bgnd.gif") as im:

info = im.info.copy()

out = str(tmp_path / "temp.gif")
im.save(out, save_all=True)
with Image.open(out) as reread:

for header in important_headers:
assert info[header] == reread.info[header]

Expand All @@ -308,7 +303,6 @@ def test_palette_handling(tmp_path):
im2.save(f, optimize=True)

with Image.open(f) as reloaded:

assert_image_similar(im, reloaded.convert("RGB"), 10)


Expand All @@ -324,7 +318,6 @@ def roundtrip(im, *args, **kwargs):

orig = "Tests/images/test.colors.gif"
with Image.open(orig) as im:

with roundtrip(im) as reloaded:
assert_image_similar(im, reloaded, 1)
with roundtrip(im, optimize=True) as reloaded:
Expand Down Expand Up @@ -575,7 +568,6 @@ def test_save_dispose(tmp_path):
)

with Image.open(out) as img:

for i in range(2):
img.seek(img.tell() + 1)
assert img.disposal_method == i + 1
Expand Down Expand Up @@ -773,7 +765,6 @@ def test_multiple_duration(tmp_path):
out, save_all=True, append_images=im_list[1:], duration=duration_list
)
with Image.open(out) as reread:

for duration in duration_list:
assert reread.info["duration"] == duration
try:
Expand All @@ -786,7 +777,6 @@ def test_multiple_duration(tmp_path):
out, save_all=True, append_images=im_list[1:], duration=tuple(duration_list)
)
with Image.open(out) as reread:

for duration in duration_list:
assert reread.info["duration"] == duration
try:
Expand Down Expand Up @@ -844,7 +834,6 @@ def test_identical_frames(tmp_path):
out, save_all=True, append_images=im_list[1:], duration=duration_list
)
with Image.open(out) as reread:

# Assert that the first three frames were combined
assert reread.n_frames == 2

Expand Down
2 changes: 0 additions & 2 deletions Tests/test_file_gribstub.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def test_open():
# Act
with Image.open(TEST_FILE) as im:

# Assert
assert im.format == "GRIB"

Expand All @@ -31,7 +30,6 @@ def test_invalid_file():
def test_load():
# Arrange
with Image.open(TEST_FILE) as im:

# Act / Assert: stub cannot load without an implemented handler
with pytest.raises(OSError):
im.load()
Expand Down
2 changes: 0 additions & 2 deletions Tests/test_file_hdf5stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
def test_open():
# Act
with Image.open(TEST_FILE) as im:

# Assert
assert im.format == "HDF5"

Expand All @@ -29,7 +28,6 @@ def test_invalid_file():
def test_load():
# Arrange
with Image.open(TEST_FILE) as im:

# Act / Assert: stub cannot load without an implemented handler
with pytest.raises(OSError):
im.load()
Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_icns.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def test_sanity():
# Loading this icon by default should result in the largest size
# (512x512@2x) being loaded
with Image.open(TEST_FILE) as im:

# Assert that there is no unclosed file warning
with warnings.catch_warnings():
im.load()
Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_ico.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def test_save_256x256(tmp_path):
# Act
im.save(outfile)
with Image.open(outfile) as im_saved:

# Assert
assert im_saved.size == (256, 256)

Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_im.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def test_context_manager():
def test_tell():
# Arrange
with Image.open(TEST_IM) as im:

# Act
frame = im.tell()

Expand Down
3 changes: 0 additions & 3 deletions Tests/test_file_iptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
def test_getiptcinfo_jpg_none():
# Arrange
with hopper() as im:

# Act
iptc = IptcImagePlugin.getiptcinfo(im)

Expand All @@ -22,7 +21,6 @@ def test_getiptcinfo_jpg_none():
def test_getiptcinfo_jpg_found():
# Arrange
with Image.open(TEST_FILE) as im:

# Act
iptc = IptcImagePlugin.getiptcinfo(im)

Expand All @@ -35,7 +33,6 @@ def test_getiptcinfo_jpg_found():
def test_getiptcinfo_tiff_none():
# Arrange
with Image.open("Tests/images/hopper.tif") as im:

# Act
iptc = IptcImagePlugin.getiptcinfo(im)

Expand Down
13 changes: 0 additions & 13 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def gen_random_image(self, size, mode="RGB"):
return Image.frombytes(mode, size, os.urandom(size[0] * size[1] * len(mode)))

def test_sanity(self):

# internal version number
assert re.search(r"\d+\.\d+$", features.version_codec("jpg"))

Expand Down Expand Up @@ -368,7 +367,6 @@ def test_exif_rollback(self):

def test_exif_gps_typeerror(self):
with Image.open("Tests/images/exif_gps_typeerror.jpg") as im:

# Should not raise a TypeError
im._getexif()

Expand Down Expand Up @@ -682,7 +680,6 @@ def test_bad_mpo_header(self):
# Shouldn't raise error
fn = "Tests/images/sugarshack_bad_mpo_header.jpg"
with pytest.warns(UserWarning, Image.open, fn) as im:

# Assert
assert im.format == "JPEG"

Expand All @@ -704,7 +701,6 @@ def test_save_tiff_with_dpi(self, tmp_path):
# Arrange
outfile = str(tmp_path / "temp.tif")
with Image.open("Tests/images/hopper.tif") as im:

# Act
im.save(outfile, "JPEG", dpi=im.info["dpi"])

Expand All @@ -731,7 +727,6 @@ def test_dpi_tuple_from_exif(self):
# This Photoshop CC 2017 image has DPI in EXIF not metadata
# EXIF XResolution is (2000000, 10000)
with Image.open("Tests/images/photoshop-200dpi.jpg") as im:

# Act / Assert
assert im.info.get("dpi") == (200, 200)

Expand All @@ -740,7 +735,6 @@ def test_dpi_int_from_exif(self):
# This image has DPI in EXIF not metadata
# EXIF XResolution is 72
with Image.open("Tests/images/exif-72dpi-int.jpg") as im:

# Act / Assert
assert im.info.get("dpi") == (72, 72)

Expand All @@ -749,7 +743,6 @@ def test_dpi_from_dpcm_exif(self):
# This is photoshop-200dpi.jpg with EXIF resolution unit set to cm:
# exiftool -exif:ResolutionUnit=cm photoshop-200dpi.jpg
with Image.open("Tests/images/exif-200dpcm.jpg") as im:

# Act / Assert
assert im.info.get("dpi") == (508, 508)

Expand All @@ -758,7 +751,6 @@ def test_dpi_exif_zero_division(self):
# This is photoshop-200dpi.jpg with EXIF resolution set to 0/0:
# exiftool -XResolution=0/0 -YResolution=0/0 photoshop-200dpi.jpg
with Image.open("Tests/images/exif-dpi-zerodivision.jpg") as im:

# Act / Assert
# This should return the default, and not raise a ZeroDivisionError
assert im.info.get("dpi") == (72, 72)
Expand All @@ -767,7 +759,6 @@ def test_dpi_exif_string(self):
# Arrange
# 0x011A tag in this exif contains string '300300\x02'
with Image.open("Tests/images/broken_exif_dpi.jpg") as im:

# Act / Assert
# This should return the default
assert im.info.get("dpi") == (72, 72)
Expand All @@ -777,7 +768,6 @@ def test_no_dpi_in_exif(self):
# This is photoshop-200dpi.jpg with resolution removed from EXIF:
# exiftool "-*resolution*"= photoshop-200dpi.jpg
with Image.open("Tests/images/no-dpi-in-exif.jpg") as im:

# Act / Assert
# "When the image resolution is unknown, 72 [dpi] is designated."
# https://exiv2.org/tags.html
Expand All @@ -787,7 +777,6 @@ def test_invalid_exif(self):
# This is no-dpi-in-exif with the tiff header of the exif block
# hexedited from MM * to FF FF FF FF
with Image.open("Tests/images/invalid-exif.jpg") as im:

# This should return the default, and not a SyntaxError or
# OSError for unidentified image.
assert im.info.get("dpi") == (72, 72)
Expand All @@ -810,7 +799,6 @@ def test_exif_x_resolution(self, tmp_path):
def test_invalid_exif_x_resolution(self):
# When no x or y resolution is defined in EXIF
with Image.open("Tests/images/invalid-exif-without-x-resolution.jpg") as im:

# This should return the default, and not a ValueError or
# OSError for an unidentified image.
assert im.info.get("dpi") == (72, 72)
Expand All @@ -820,7 +808,6 @@ def test_ifd_offset_exif(self):
# This image has been manually hexedited to have an IFD offset of 10,
# in contrast to normal 8
with Image.open("Tests/images/exif-ifd-offset.jpg") as im:

# Act / Assert
assert im._getexif()[306] == "2017:03:13 23:03:09"

Expand Down
1 change: 0 additions & 1 deletion Tests/test_file_jpeg2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def test_rgba():
# Arrange
with Image.open("Tests/images/rgb_trns_ycbc.j2k") as j2k:
with Image.open("Tests/images/rgb_trns_ycbc.jp2") as jp2:

# Act
j2k.load()
jp2.load()
Expand Down
Loading

0 comments on commit 55d6cf5

Please sign in to comment.