mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Merge pull request #7480 from radarhere/lint
This commit is contained in:
commit
a10dec01b5
|
@ -26,8 +26,7 @@ def open_with_magick(magick, tmp_path, f):
|
||||||
rc = subprocess.call(
|
rc = subprocess.call(
|
||||||
magick + [f, outfile], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT
|
magick + [f, outfile], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
if rc:
|
assert not rc
|
||||||
raise OSError
|
|
||||||
return Image.open(outfile)
|
return Image.open(outfile)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,8 @@ class FliImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
s = self.fp.read(4)
|
s = self.fp.read(4)
|
||||||
if not s:
|
if not s:
|
||||||
raise EOFError
|
msg = "missing frame size"
|
||||||
|
raise EOFError(msg)
|
||||||
|
|
||||||
framesize = i32(s)
|
framesize = i32(s)
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,8 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
s = self.fp.read(1)
|
s = self.fp.read(1)
|
||||||
if not s or s == b";":
|
if not s or s == b";":
|
||||||
raise EOFError
|
msg = "no more images in GIF file"
|
||||||
|
raise EOFError(msg)
|
||||||
|
|
||||||
palette = None
|
palette = None
|
||||||
|
|
||||||
|
@ -288,7 +289,8 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
if interlace is None:
|
if interlace is None:
|
||||||
# self._fp = None
|
# self._fp = None
|
||||||
raise EOFError
|
msg = "image not found in GIF frame"
|
||||||
|
raise EOFError(msg)
|
||||||
|
|
||||||
self.__frame = frame
|
self.__frame = frame
|
||||||
if not update_image:
|
if not update_image:
|
||||||
|
|
|
@ -1862,7 +1862,8 @@ class Image:
|
||||||
# do things the hard way
|
# do things the hard way
|
||||||
im = self.im.convert(mode)
|
im = self.im.convert(mode)
|
||||||
if im.mode not in ("LA", "PA", "RGBA"):
|
if im.mode not in ("LA", "PA", "RGBA"):
|
||||||
raise ValueError from e # sanity check
|
msg = "alpha channel could not be added"
|
||||||
|
raise ValueError(msg) from e # sanity check
|
||||||
self.im = im
|
self.im = im
|
||||||
self.pyaccess = None
|
self.pyaccess = None
|
||||||
self._mode = self.im.mode
|
self._mode = self.im.mode
|
||||||
|
@ -2467,7 +2468,8 @@ class Image:
|
||||||
|
|
||||||
# overridden by file handlers
|
# overridden by file handlers
|
||||||
if frame != 0:
|
if frame != 0:
|
||||||
raise EOFError
|
msg = "no more images in file"
|
||||||
|
raise EOFError(msg)
|
||||||
|
|
||||||
def show(self, title=None):
|
def show(self, title=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -200,8 +200,8 @@ class ImageFile(Image.Image):
|
||||||
with open(self.filename) as fp:
|
with open(self.filename) as fp:
|
||||||
self.map = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
|
self.map = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
|
||||||
if offset + self.size[1] * args[1] > self.map.size():
|
if offset + self.size[1] * args[1] > self.map.size():
|
||||||
# buffer is not large enough
|
msg = "buffer is not large enough"
|
||||||
raise OSError
|
raise OSError(msg)
|
||||||
self.im = Image.core.map_buffer(
|
self.im = Image.core.map_buffer(
|
||||||
self.map, self.size, decoder_name, offset, args
|
self.map, self.size, decoder_name, offset, args
|
||||||
)
|
)
|
||||||
|
@ -690,7 +690,8 @@ class PyDecoder(PyCodec):
|
||||||
If finished with decoding return -1 for the bytes consumed.
|
If finished with decoding return -1 for the bytes consumed.
|
||||||
Err codes are from :data:`.ImageFile.ERRORS`.
|
Err codes are from :data:`.ImageFile.ERRORS`.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
msg = "unavailable in base decoder"
|
||||||
|
raise NotImplementedError(msg)
|
||||||
|
|
||||||
def set_as_raw(self, data, rawmode=None):
|
def set_as_raw(self, data, rawmode=None):
|
||||||
"""
|
"""
|
||||||
|
@ -739,7 +740,8 @@ class PyEncoder(PyCodec):
|
||||||
If finished with encoding return 1 for the error code.
|
If finished with encoding return 1 for the error code.
|
||||||
Err codes are from :data:`.ImageFile.ERRORS`.
|
Err codes are from :data:`.ImageFile.ERRORS`.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
msg = "unavailable in base encoder"
|
||||||
|
raise NotImplementedError(msg)
|
||||||
|
|
||||||
def encode_to_pyfd(self):
|
def encode_to_pyfd(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -205,7 +205,8 @@ def make_linear_lut(black, white):
|
||||||
for i in range(256):
|
for i in range(256):
|
||||||
lut.append(white * i // 255)
|
lut.append(white * i // 255)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError # FIXME
|
msg = "unavailable when black is non-zero"
|
||||||
|
raise NotImplementedError(msg) # FIXME
|
||||||
return lut
|
return lut
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ class Iterator:
|
||||||
self.im.seek(ix)
|
self.im.seek(ix)
|
||||||
return self.im
|
return self.im
|
||||||
except EOFError as e:
|
except EOFError as e:
|
||||||
raise IndexError from e # end of sequence
|
msg = "end of sequence"
|
||||||
|
raise IndexError(msg) from e
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
@ -51,7 +52,8 @@ class Iterator:
|
||||||
self.position += 1
|
self.position += 1
|
||||||
return self.im
|
return self.im
|
||||||
except EOFError as e:
|
except EOFError as e:
|
||||||
raise StopIteration from e
|
msg = "end of sequence"
|
||||||
|
raise StopIteration(msg) from e
|
||||||
|
|
||||||
|
|
||||||
def all_frames(im, func=None):
|
def all_frames(im, func=None):
|
||||||
|
|
|
@ -99,7 +99,8 @@ class Viewer:
|
||||||
Returns the command used to display the file.
|
Returns the command used to display the file.
|
||||||
Not implemented in the base class.
|
Not implemented in the base class.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
msg = "unavailable in base viewer"
|
||||||
|
raise NotImplementedError(msg)
|
||||||
|
|
||||||
def save_image(self, image):
|
def save_image(self, image):
|
||||||
"""Save to temporary file and return filename."""
|
"""Save to temporary file and return filename."""
|
||||||
|
|
|
@ -165,7 +165,8 @@ def APP(self, marker):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
dpi = x_resolution
|
dpi = x_resolution
|
||||||
if math.isnan(dpi):
|
if math.isnan(dpi):
|
||||||
raise ValueError
|
msg = "DPI is not a number"
|
||||||
|
raise ValueError(msg)
|
||||||
if resolution_unit == 3: # cm
|
if resolution_unit == 3: # cm
|
||||||
# 1 dpcm = 2.54 dpi
|
# 1 dpcm = 2.54 dpi
|
||||||
dpi *= 2.54
|
dpi *= 2.54
|
||||||
|
@ -719,7 +720,8 @@ def _save(im, fp, filename):
|
||||||
for idx, table in enumerate(qtables):
|
for idx, table in enumerate(qtables):
|
||||||
try:
|
try:
|
||||||
if len(table) != 64:
|
if len(table) != 64:
|
||||||
raise TypeError
|
msg = "Invalid quantization table"
|
||||||
|
raise TypeError(msg)
|
||||||
table = array.array("H", table)
|
table = array.array("H", table)
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
msg = "Invalid quantization table"
|
msg = "Invalid quantization table"
|
||||||
|
|
|
@ -438,11 +438,12 @@ class PngStream(ChunkStream):
|
||||||
tile = [("zip", (0, 0) + self.im_size, pos, self.im_rawmode)]
|
tile = [("zip", (0, 0) + self.im_size, pos, self.im_rawmode)]
|
||||||
self.im_tile = tile
|
self.im_tile = tile
|
||||||
self.im_idat = length
|
self.im_idat = length
|
||||||
raise EOFError
|
msg = "image data found"
|
||||||
|
raise EOFError(msg)
|
||||||
|
|
||||||
def chunk_IEND(self, pos, length):
|
def chunk_IEND(self, pos, length):
|
||||||
# end of PNG image
|
msg = "end of PNG image"
|
||||||
raise EOFError
|
raise EOFError(msg)
|
||||||
|
|
||||||
def chunk_PLTE(self, pos, length):
|
def chunk_PLTE(self, pos, length):
|
||||||
# palette
|
# palette
|
||||||
|
@ -891,7 +892,8 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
self.dispose_extent = self.info.get("bbox")
|
self.dispose_extent = self.info.get("bbox")
|
||||||
|
|
||||||
if not self.tile:
|
if not self.tile:
|
||||||
raise EOFError
|
msg = "image not found in APNG frame"
|
||||||
|
raise EOFError(msg)
|
||||||
|
|
||||||
# setup frame disposal (actual disposal done when needed in the next _seek())
|
# setup frame disposal (actual disposal done when needed in the next _seek())
|
||||||
if self._prev_im is None and self.dispose_op == Disposal.OP_PREVIOUS:
|
if self._prev_im is None and self.dispose_op == Disposal.OP_PREVIOUS:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user