[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2022-03-06 02:39:06 +00:00
parent d20f39d02e
commit 0215175e1d
2 changed files with 5 additions and 5 deletions

View File

@ -86,7 +86,7 @@ def test_32bit_plain_pgm(tmp_path):
def test_plain_pbm_data_with_comments(tmp_path):
path1 = str(tmp_path / "temp1.ppm")
path2 = str(tmp_path / "temp2.ppm")
comment = b"# veeery long comment" * 10 ** 6
comment = b"# veeery long comment" * 10**6
with open(path1, "wb") as f1, open(path2, "wb") as f2:
f1.write(b"P1\n2 2\n\n1010")
f2.write(b"P1\n2 2\n" + comment + b"\n1010" + comment)
@ -118,7 +118,7 @@ def test_plain_pbm_invalid_data(tmp_path):
def test_plain_ppm_data_with_comments(tmp_path):
path1 = str(tmp_path / "temp1.ppm")
path2 = str(tmp_path / "temp2.ppm")
comment = b"# veeery long comment" * 10 ** 6
comment = b"# veeery long comment" * 10**6
with open(path1, "wb") as f1, open(path2, "wb") as f2:
f1.write(b"P3\n2 2\n255\n0 0 0 001 1 1 2 2 2 255 255 255")
f2.write(

View File

@ -145,7 +145,7 @@ class PpmImageFile(ImageFile.ImageFile):
class PpmPlainDecoder(ImageFile.PyDecoder):
_pulls_fd = True
def _read_block(self, block_size=10 ** 6):
def _read_block(self, block_size=10**6):
return bytearray(self.fd.read(block_size))
def _find_comment_end(self, block, start=0):
@ -218,9 +218,9 @@ class PpmPlainDecoder(ImageFile.PyDecoder):
def _decode_blocks(self, channels=1, depth=8):
decoded_data = bytearray()
if depth == 32:
maxval = 2 ** 31 - 1 # HACK: 32-bit grayscale uses signed int
maxval = 2**31 - 1 # HACK: 32-bit grayscale uses signed int
else:
maxval = 2 ** depth - 1 # FIXME: should be passed by _open
maxval = 2**depth - 1 # FIXME: should be passed by _open
max_len = 10
bytes_per_sample = depth // 8
total_tokens = self.size * channels