From ee85e387bab535e2339b9d3cd1ab87c61d23af15 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sun, 10 Apr 2022 19:25:40 +0300 Subject: [PATCH] Remove redundant parentheses --- Tests/test_image_resample.py | 2 +- selftest.py | 2 +- setup.py | 2 +- src/PIL/BlpImagePlugin.py | 2 +- src/PIL/EpsImagePlugin.py | 2 +- src/PIL/FtexImagePlugin.py | 2 +- src/PIL/ImageCms.py | 4 ++-- src/PIL/ImageColor.py | 10 +++++----- src/PIL/ImageFile.py | 4 ++-- src/PIL/Jpeg2KImagePlugin.py | 4 ++-- src/PIL/JpegImagePlugin.py | 2 +- src/PIL/PyAccess.py | 6 +++--- src/PIL/TiffImagePlugin.py | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 125422337..6d050efcc 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -458,7 +458,7 @@ class TestCoreResampleBox: 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]) diff --git a/selftest.py b/selftest.py index 5010c1213..6eeadd1db 100755 --- a/selftest.py +++ b/selftest.py @@ -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) diff --git a/setup.py b/setup.py index 3468b260d..9a05e5105 100755 --- a/setup.py +++ b/setup.py @@ -269,7 +269,7 @@ def _pkg_config(name): .strip() .replace("-I", "") ) - return (libs, cflags) + return libs, cflags except Exception: pass diff --git a/src/PIL/BlpImagePlugin.py b/src/PIL/BlpImagePlugin.py index ecd3da5df..e4e029596 100644 --- a/src/PIL/BlpImagePlugin.py +++ b/src/PIL/BlpImagePlugin.py @@ -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): diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py index b67363beb..3b782d6b3 100644 --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -325,7 +325,7 @@ class EpsImageFile(ImageFile.ImageFile): else: raise SyntaxError("not an EPS file") - return (length, offset) + return length, offset def load(self, scale=1, transparency=False): # Load EPS via Ghostscript diff --git a/src/PIL/FtexImagePlugin.py b/src/PIL/FtexImagePlugin.py index 55d28e1ff..1d74390d8 100644 --- a/src/PIL/FtexImagePlugin.py +++ b/src/PIL/FtexImagePlugin.py @@ -114,7 +114,7 @@ class FtexImageFile(ImageFile.ImageFile): 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: diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index ea328e149..5a2dbae50 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -162,7 +162,7 @@ FLAGS = { "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 @@ -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__ diff --git a/src/PIL/ImageColor.py b/src/PIL/ImageColor.py index 25f92f2c7..13510e4d4 100644 --- a/src/PIL/ImageColor.py +++ b/src/PIL/ImageColor.py @@ -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 ( @@ -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 ( @@ -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: @@ -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)}") @@ -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,) diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index 34f344f1d..3f8c2abe7 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -571,7 +571,7 @@ class PyCodecState: 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: @@ -681,7 +681,7 @@ class PyDecoder(PyCodec): 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) diff --git a/src/PIL/Jpeg2KImagePlugin.py b/src/PIL/Jpeg2KImagePlugin.py index fb5d70cee..c67d8d6bf 100644 --- a/src/PIL/Jpeg2KImagePlugin.py +++ b/src/PIL/Jpeg2KImagePlugin.py @@ -124,7 +124,7 @@ def _parse_codestream(fp): else: mode = None - return (size, mode) + return size, mode def _res_to_dpi(num, denom, exp): @@ -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 ## diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index 93741ec6e..aae2a4591 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -444,7 +444,7 @@ class JpegImageFile(ImageFile.ImageFile): 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): diff --git a/src/PIL/PyAccess.py b/src/PIL/PyAccess.py index eeaa0ccc4..5280e2a49 100644 --- a/src/PIL/PyAccess.py +++ b/src/PIL/PyAccess.py @@ -135,7 +135,7 @@ class _PyAccess32_2(PyAccess): 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] @@ -152,7 +152,7 @@ class _PyAccess32_3(PyAccess): 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] @@ -171,7 +171,7 @@ class _PyAccess32_4(PyAccess): 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] diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index e96f58440..b2d15d807 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -353,10 +353,10 @@ class IFDRational(Rational): """ 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))