Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Aug 12, 2019
1 parent 1b626f4 commit 524933a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,24 @@ def _setitem(self, tag, value, legacy_api):
else:
self.tagtype[tag] = TiffTags.UNDEFINED
if all(isinstance(v, IFDRational) for v in values):
self.tagtype[tag] = TiffTags.RATIONAL if all(v >= 0 for v in values) else TiffTags.SIGNED_RATIONAL
self.tagtype[tag] = (
TiffTags.RATIONAL
if all(v >= 0 for v in values)
else TiffTags.SIGNED_RATIONAL
)
elif all(isinstance(v, int) for v in values):
if all(v < 2 ** 16 for v in values):
self.tagtype[tag] = TiffTags.SHORT if all(v >= 0 for v in values) else TiffTags.SIGNED_SHORT
self.tagtype[tag] = (
TiffTags.SHORT
if all(v >= 0 for v in values)
else TiffTags.SIGNED_SHORT
)
else:
self.tagtype[tag] = TiffTags.LONG if all(v >= 0 for v in values) else TiffTags.SIGNED_LONG
self.tagtype[tag] = (
TiffTags.LONG
if all(v >= 0 for v in values)
else TiffTags.SIGNED_LONG
)
elif all(isinstance(v, float) for v in values):
self.tagtype[tag] = TiffTags.DOUBLE
else:
Expand Down Expand Up @@ -744,7 +756,8 @@ def combine(a, b):
@_register_writer(10)
def write_signed_rational(self, *values):
return b"".join(
self._pack("2l", *_limit_signed_rational(frac, 2 ** 31 - 1, -2 ** 31)) for frac in values
self._pack("2l", *_limit_signed_rational(frac, 2 ** 31 - 1, -2 ** 31))
for frac in values
)

def _ensure_read(self, fp, size):
Expand Down

0 comments on commit 524933a

Please sign in to comment.