Merge pull request #4180 from radarhere/black

Lint fixes
This commit is contained in:
Hugo van Kemenade 2019-10-29 17:26:14 +01:00 committed by GitHub
commit bb1fc75e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 29 deletions

View File

@ -119,7 +119,7 @@ def decode_dxt3(data):
bits = struct.unpack_from("<8B", block) bits = struct.unpack_from("<8B", block)
color0, color1 = struct.unpack_from("<HH", block, 8) color0, color1 = struct.unpack_from("<HH", block, 8)
code, = struct.unpack_from("<I", block, 12) (code,) = struct.unpack_from("<I", block, 12)
r0, g0, b0 = unpack_565(color0) r0, g0, b0 = unpack_565(color0)
r1, g1, b1 = unpack_565(color1) r1, g1, b1 = unpack_565(color1)
@ -177,7 +177,7 @@ def decode_dxt5(data):
color0, color1 = struct.unpack_from("<HH", block, 8) color0, color1 = struct.unpack_from("<HH", block, 8)
code, = struct.unpack_from("<I", block, 12) (code,) = struct.unpack_from("<I", block, 12)
r0, g0, b0 = unpack_565(color0) r0, g0, b0 = unpack_565(color0)
r1, g1, b1 = unpack_565(color1) r1, g1, b1 = unpack_565(color1)
@ -255,19 +255,19 @@ class BlpImageFile(ImageFile.ImageFile):
self.tile = [(decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))] self.tile = [(decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]
def _read_blp_header(self): def _read_blp_header(self):
self._blp_compression, = struct.unpack("<i", self.fp.read(4)) (self._blp_compression,) = struct.unpack("<i", self.fp.read(4))
self._blp_encoding, = struct.unpack("<b", self.fp.read(1)) (self._blp_encoding,) = struct.unpack("<b", self.fp.read(1))
self._blp_alpha_depth, = struct.unpack("<b", self.fp.read(1)) (self._blp_alpha_depth,) = struct.unpack("<b", self.fp.read(1))
self._blp_alpha_encoding, = struct.unpack("<b", self.fp.read(1)) (self._blp_alpha_encoding,) = struct.unpack("<b", self.fp.read(1))
self._blp_mips, = struct.unpack("<b", self.fp.read(1)) (self._blp_mips,) = struct.unpack("<b", self.fp.read(1))
self._size = struct.unpack("<II", self.fp.read(8)) self._size = struct.unpack("<II", self.fp.read(8))
if self.magic == b"BLP1": if self.magic == b"BLP1":
# Only present for BLP1 # Only present for BLP1
self._blp_encoding, = struct.unpack("<i", self.fp.read(4)) (self._blp_encoding,) = struct.unpack("<i", self.fp.read(4))
self._blp_subtype, = struct.unpack("<i", self.fp.read(4)) (self._blp_subtype,) = struct.unpack("<i", self.fp.read(4))
self._blp_offsets = struct.unpack("<16I", self.fp.read(16 * 4)) self._blp_offsets = struct.unpack("<16I", self.fp.read(16 * 4))
self._blp_lengths = struct.unpack("<16I", self.fp.read(16 * 4)) self._blp_lengths = struct.unpack("<16I", self.fp.read(16 * 4))
@ -297,19 +297,19 @@ class _BLPBaseDecoder(ImageFile.PyDecoder):
return ret return ret
def _read_blp_header(self): def _read_blp_header(self):
self._blp_compression, = struct.unpack("<i", self.fd.read(4)) (self._blp_compression,) = struct.unpack("<i", self.fd.read(4))
self._blp_encoding, = struct.unpack("<b", self.fd.read(1)) (self._blp_encoding,) = struct.unpack("<b", self.fd.read(1))
self._blp_alpha_depth, = struct.unpack("<b", self.fd.read(1)) (self._blp_alpha_depth,) = struct.unpack("<b", self.fd.read(1))
self._blp_alpha_encoding, = struct.unpack("<b", self.fd.read(1)) (self._blp_alpha_encoding,) = struct.unpack("<b", self.fd.read(1))
self._blp_mips, = struct.unpack("<b", self.fd.read(1)) (self._blp_mips,) = struct.unpack("<b", self.fd.read(1))
self.size = struct.unpack("<II", self.fd.read(8)) self.size = struct.unpack("<II", self.fd.read(8))
if self.magic == b"BLP1": if self.magic == b"BLP1":
# Only present for BLP1 # Only present for BLP1
self._blp_encoding, = struct.unpack("<i", self.fd.read(4)) (self._blp_encoding,) = struct.unpack("<i", self.fd.read(4))
self._blp_subtype, = struct.unpack("<i", self.fd.read(4)) (self._blp_subtype,) = struct.unpack("<i", self.fd.read(4))
self._blp_offsets = struct.unpack("<16I", self.fd.read(16 * 4)) self._blp_offsets = struct.unpack("<16I", self.fd.read(16 * 4))
self._blp_lengths = struct.unpack("<16I", self.fd.read(16 * 4)) self._blp_lengths = struct.unpack("<16I", self.fd.read(16 * 4))
@ -327,7 +327,7 @@ class BLP1Decoder(_BLPBaseDecoder):
_data = BytesIO(self.fd.read(self._blp_lengths[0])) _data = BytesIO(self.fd.read(self._blp_lengths[0]))
while True: while True:
try: try:
offset, = struct.unpack("<B", _data.read(1)) (offset,) = struct.unpack("<B", _data.read(1))
except struct.error: except struct.error:
break break
b, g, r, a = palette[offset] b, g, r, a = palette[offset]
@ -346,7 +346,7 @@ class BLP1Decoder(_BLPBaseDecoder):
def _decode_jpeg_stream(self): def _decode_jpeg_stream(self):
from PIL.JpegImagePlugin import JpegImageFile from PIL.JpegImagePlugin import JpegImageFile
jpeg_header_size, = struct.unpack("<I", self.fd.read(4)) (jpeg_header_size,) = struct.unpack("<I", self.fd.read(4))
jpeg_header = self.fd.read(jpeg_header_size) jpeg_header = self.fd.read(jpeg_header_size)
self.fd.read(self._blp_offsets[0] - self.fd.tell()) # What IS this? self.fd.read(self._blp_offsets[0] - self.fd.tell()) # What IS this?
data = self.fd.read(self._blp_lengths[0]) data = self.fd.read(self._blp_lengths[0])
@ -372,7 +372,7 @@ class BLP2Decoder(_BLPBaseDecoder):
_data = BytesIO(self.fd.read(self._blp_lengths[0])) _data = BytesIO(self.fd.read(self._blp_lengths[0]))
while True: while True:
try: try:
offset, = struct.unpack("<B", _data.read(1)) (offset,) = struct.unpack("<B", _data.read(1))
except struct.error: except struct.error:
break break
b, g, r, a = palette[offset] b, g, r, a = palette[offset]

View File

@ -122,7 +122,7 @@ class DdsImageFile(ImageFile.ImageFile):
# pixel format # pixel format
pfsize, pfflags = struct.unpack("<2I", header.read(8)) pfsize, pfflags = struct.unpack("<2I", header.read(8))
fourcc = header.read(4) fourcc = header.read(4)
bitcount, = struct.unpack("<I", header.read(4)) (bitcount,) = struct.unpack("<I", header.read(4))
masks = struct.unpack("<4I", header.read(16)) masks = struct.unpack("<4I", header.read(16))
if pfflags & 0x40: if pfflags & 0x40:
# DDPF_RGB - Texture contains uncompressed RGB data # DDPF_RGB - Texture contains uncompressed RGB data

View File

@ -79,7 +79,7 @@ class FtexImageFile(ImageFile.ImageFile):
format, where = struct.unpack("<2i", self.fp.read(8)) format, where = struct.unpack("<2i", self.fp.read(8))
self.fp.seek(where) self.fp.seek(where)
mipmap_size, = struct.unpack("<i", self.fp.read(4)) (mipmap_size,) = struct.unpack("<i", self.fp.read(4))
data = self.fp.read(mipmap_size) data = self.fp.read(mipmap_size)

View File

@ -3227,7 +3227,7 @@ class Exif(MutableMapping):
continue continue
size = count * unit_size size = count * unit_size
if size > 4: if size > 4:
offset, = struct.unpack("<L", data) (offset,) = struct.unpack("<L", data)
data = ifd_data[offset - 12 : offset + size - 12] data = ifd_data[offset - 12 : offset + size - 12]
else: else:
data = data[:size] data = data[:size]
@ -3257,7 +3257,7 @@ class Exif(MutableMapping):
) )
if ifd_tag == 0x1101: if ifd_tag == 0x1101:
# CameraInfo # CameraInfo
offset, = struct.unpack(">L", data) (offset,) = struct.unpack(">L", data)
self.fp.seek(offset) self.fp.seek(offset)
camerainfo = {"ModelID": self.fp.read(4)} camerainfo = {"ModelID": self.fp.read(4)}

View File

@ -484,7 +484,7 @@ class ImageFileDirectory_v2(MutableMapping):
else: else:
raise SyntaxError("not a TIFF IFD") raise SyntaxError("not a TIFF IFD")
self.reset() self.reset()
self.next, = self._unpack("L", ifh[4:]) (self.next,) = self._unpack("L", ifh[4:])
self._legacy_api = False self._legacy_api = False
prefix = property(lambda self: self._prefix) prefix = property(lambda self: self._prefix)
@ -595,7 +595,7 @@ class ImageFileDirectory_v2(MutableMapping):
]: # rationals ]: # rationals
values = (values,) values = (values,)
try: try:
dest[tag], = values (dest[tag],) = values
except ValueError: except ValueError:
# We've got a builtin tag with 1 expected entry # We've got a builtin tag with 1 expected entry
warnings.warn( warnings.warn(
@ -765,7 +765,7 @@ class ImageFileDirectory_v2(MutableMapping):
size = count * unit_size size = count * unit_size
if size > 4: if size > 4:
here = fp.tell() here = fp.tell()
offset, = self._unpack("L", data) (offset,) = self._unpack("L", data)
if DEBUG: if DEBUG:
print( print(
"Tag Location: %s - Data Location: %s" % (here, offset), "Tag Location: %s - Data Location: %s" % (here, offset),
@ -797,7 +797,7 @@ class ImageFileDirectory_v2(MutableMapping):
else: else:
print("- value:", self[tag]) print("- value:", self[tag])
self.next, = self._unpack("L", self._ensure_read(fp, 4)) (self.next,) = self._unpack("L", self._ensure_read(fp, 4))
except IOError as msg: except IOError as msg:
warnings.warn(str(msg)) warnings.warn(str(msg))
return return
@ -1796,11 +1796,11 @@ class AppendingTiffWriter:
return self.f.write(data) return self.f.write(data)
def readShort(self): def readShort(self):
value, = struct.unpack(self.shortFmt, self.f.read(2)) (value,) = struct.unpack(self.shortFmt, self.f.read(2))
return value return value
def readLong(self): def readLong(self):
value, = struct.unpack(self.longFmt, self.f.read(4)) (value,) = struct.unpack(self.longFmt, self.f.read(4))
return value return value
def rewriteLastShortToLong(self, value): def rewriteLastShortToLong(self, value):