Skip to content

Commit

Permalink
Remove redundant parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Apr 10, 2022
1 parent 6a648c9 commit ee85e38
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Tests/test_image_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def resize_tiled(self, im, dst_size, xtiles, ytiles):
def split_range(size, tiles):
scale = size / tiles
for i in range(tiles):
yield (int(round(scale * i)), int(round(scale * (i + 1))))
yield int(round(scale * i)), int(round(scale * (i + 1)))

tiled = Image.new(im.mode, dst_size)
scale = (im.size[0] / tiled.size[0], im.size[1] / tiled.size[1])
Expand Down
2 changes: 1 addition & 1 deletion selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def testimage():
>>> from PIL import Image, ImageDraw, ImageFilter, ImageMath
>>> im = Image.new("1", (128, 128)) # monochrome
>>> def _info(im): return (im.format, im.mode, im.size)
>>> def _info(im): return im.format, im.mode, im.size
>>> _info(im)
(None, '1', (128, 128))
>>> _info(Image.new("L", (128, 128))) # grayscale (luminance)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _pkg_config(name):
.strip()
.replace("-I", "")
)
return (libs, cflags)
return libs, cflags
except Exception:
pass

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/BlpImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __getattr__(name):


def unpack_565(i):
return (((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3)
return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3


def decode_dxt1(data, alpha=False):
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _find_offset(self, fp):
else:
raise SyntaxError("not an EPS file")

return (length, offset)
return length, offset

def load(self, scale=1, transparency=False):
# Load EPS via Ghostscript
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FtexImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _open(self):

if format == Format.DXT1:
self.mode = "RGBA"
self.tile = [("bcn", (0, 0) + self.size, 0, (1))]
self.tile = [("bcn", (0, 0) + self.size, 0, 1)]
elif format == Format.UNCOMPRESSED:
self.tile = [("raw", (0, 0) + self.size, 0, ("RGB", 0, 1))]
else:
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __getattr__(name):
"SOFTPROOFING": 16384, # Do softproofing
"PRESERVEBLACK": 32768, # Black preservation
"NODEFAULTRESOURCEDEF": 16777216, # CRD special
"GRIDPOINTS": lambda n: ((n) & 0xFF) << 16, # Gridpoints
"GRIDPOINTS": lambda n: (n & 0xFF) << 16, # Gridpoints
}

_MAX_FLAG = 0
Expand Down Expand Up @@ -1026,4 +1026,4 @@ def versions():
(pyCMS) Fetches versions.
"""

return (VERSION, core.littlecms_version, sys.version.split()[0], Image.__version__)
return VERSION, core.littlecms_version, sys.version.split()[0], Image.__version__
10 changes: 5 additions & 5 deletions src/PIL/ImageColor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def getrgb(color):

# check for known string formats
if re.match("#[a-f0-9]{3}$", color):
return (int(color[1] * 2, 16), int(color[2] * 2, 16), int(color[3] * 2, 16))
return int(color[1] * 2, 16), int(color[2] * 2, 16), int(color[3] * 2, 16)

if re.match("#[a-f0-9]{4}$", color):
return (
Expand All @@ -56,7 +56,7 @@ def getrgb(color):
)

if re.match("#[a-f0-9]{6}$", color):
return (int(color[1:3], 16), int(color[3:5], 16), int(color[5:7], 16))
return int(color[1:3], 16), int(color[3:5], 16), int(color[5:7], 16)

if re.match("#[a-f0-9]{8}$", color):
return (
Expand All @@ -68,7 +68,7 @@ def getrgb(color):

m = re.match(r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$", color)
if m:
return (int(m.group(1)), int(m.group(2)), int(m.group(3)))
return int(m.group(1)), int(m.group(2)), int(m.group(3))

m = re.match(r"rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$", color)
if m:
Expand Down Expand Up @@ -114,7 +114,7 @@ def getrgb(color):

m = re.match(r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$", color)
if m:
return (int(m.group(1)), int(m.group(2)), int(m.group(3)), int(m.group(4)))
return int(m.group(1)), int(m.group(2)), int(m.group(3)), int(m.group(4))
raise ValueError(f"unknown color specifier: {repr(color)}")


Expand All @@ -140,7 +140,7 @@ def getcolor(color, mode):
# scaled to 24 bits to match the convert's implementation.
color = (r * 19595 + g * 38470 + b * 7471 + 0x8000) >> 16
if mode[-1] == "A":
return (color, alpha)
return color, alpha
else:
if mode[-1] == "A":
return color + (alpha,)
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def __init__(self):
self.yoff = 0

def extents(self):
return (self.xoff, self.yoff, self.xoff + self.xsize, self.yoff + self.ysize)
return self.xoff, self.yoff, self.xoff + self.xsize, self.yoff + self.ysize


class PyCodec:
Expand Down Expand Up @@ -681,7 +681,7 @@ def set_as_raw(self, data, rawmode=None):

if not rawmode:
rawmode = self.mode
d = Image._getdecoder(self.mode, "raw", (rawmode))
d = Image._getdecoder(self.mode, "raw", rawmode)
d.setimage(self.im, self.state.extents())
s = d.decode(data)

Expand Down
4 changes: 2 additions & 2 deletions src/PIL/Jpeg2KImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _parse_codestream(fp):
else:
mode = None

return (size, mode)
return size, mode


def _res_to_dpi(num, denom, exp):
Expand Down Expand Up @@ -191,7 +191,7 @@ def _parse_jp2_header(fp):
if size is None or mode is None:
raise SyntaxError("Malformed JP2 header")

return (size, mode, mimetype, dpi)
return size, mode, mimetype, dpi


##
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def draft(self, mode, size):
self.decoderconfig = (scale, 0)

box = (0, 0, original_size[0] / scale, original_size[1] / scale)
return (self.mode, box)
return self.mode, box

def load_djpeg(self):

Expand Down
6 changes: 3 additions & 3 deletions src/PIL/PyAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _post_init(self, *args, **kwargs):

def get_pixel(self, x, y):
pixel = self.pixels[y][x]
return (pixel.r, pixel.a)
return pixel.r, pixel.a

def set_pixel(self, x, y, color):
pixel = self.pixels[y][x]
Expand All @@ -152,7 +152,7 @@ def _post_init(self, *args, **kwargs):

def get_pixel(self, x, y):
pixel = self.pixels[y][x]
return (pixel.r, pixel.g, pixel.b)
return pixel.r, pixel.g, pixel.b

def set_pixel(self, x, y, color):
pixel = self.pixels[y][x]
Expand All @@ -171,7 +171,7 @@ def _post_init(self, *args, **kwargs):

def get_pixel(self, x, y):
pixel = self.pixels[y][x]
return (pixel.r, pixel.g, pixel.b, pixel.a)
return pixel.r, pixel.g, pixel.b, pixel.a

def set_pixel(self, x, y, color):
pixel = self.pixels[y][x]
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ def limit_rational(self, max_denominator):
"""

if self.denominator == 0:
return (self.numerator, self.denominator)
return self.numerator, self.denominator

f = self._val.limit_denominator(max_denominator)
return (f.numerator, f.denominator)
return f.numerator, f.denominator

def __repr__(self):
return str(float(self._val))
Expand Down

0 comments on commit ee85e38

Please sign in to comment.