From cae17eb927a82c89ce096c07a3ec08cc6239872a Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 5 Nov 2016 10:31:11 -0700 Subject: [PATCH] Use more Pythonic super() instead of referencing parent class https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ --- Tests/test_imageqt.py | 4 ++-- src/PIL/BdfFontFile.py | 3 +-- src/PIL/ImageFile.py | 2 +- src/PIL/ImageQt.py | 3 +-- src/PIL/ImageTk.py | 2 +- src/PIL/ImageWin.py | 2 +- src/PIL/PcfFontFile.py | 2 +- src/PIL/PngImagePlugin.py | 3 +-- src/PIL/TarIO.py | 2 +- src/PIL/TiffImagePlugin.py | 2 +- 10 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index 9248291c3..5cf14adda 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -25,7 +25,7 @@ class PillowQtTestCase(object): class PillowQPixmapTestCase(PillowQtTestCase): def setUp(self): - PillowQtTestCase.setUp(self) + super().setUp() try: if ImageQt.qt_version == "5": from PyQt5.QtGui import QGuiApplication @@ -37,7 +37,7 @@ class PillowQPixmapTestCase(PillowQtTestCase): self.app = QGuiApplication([]) def tearDown(self): - PillowQtTestCase.tearDown(self) + super().tearDown() self.app.quit() diff --git a/src/PIL/BdfFontFile.py b/src/PIL/BdfFontFile.py index fdf2c097e..53a890fb6 100644 --- a/src/PIL/BdfFontFile.py +++ b/src/PIL/BdfFontFile.py @@ -85,8 +85,7 @@ def bdf_char(f): class BdfFontFile(FontFile.FontFile): def __init__(self, fp): - - FontFile.FontFile.__init__(self) + super().__init__() s = fp.readline() if s[:13] != b"STARTFONT 2.1": diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index 836e6318c..a275f95d2 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -78,7 +78,7 @@ class ImageFile(Image.Image): "Base class for image file format handlers." def __init__(self, fp=None, filename=None): - Image.Image.__init__(self) + super().__init__() self._min_frame = 0 diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index da60cacd0..f49725b5f 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -180,8 +180,7 @@ if qt_is_installed: # buffer, so this buffer has to hang on for the life of the image. # Fixes https://github.com/python-pillow/Pillow/issues/1370 self.__data = im_data["data"] - QImage.__init__( - self, + super().__init__( self.__data, im_data["im"].size[0], im_data["im"].size[1], diff --git a/src/PIL/ImageTk.py b/src/PIL/ImageTk.py index fd480007a..bb825f353 100644 --- a/src/PIL/ImageTk.py +++ b/src/PIL/ImageTk.py @@ -296,7 +296,7 @@ def _show(image, title): self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) - tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) + super().__init__(master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") diff --git a/src/PIL/ImageWin.py b/src/PIL/ImageWin.py index ed2c18ec4..c654569c5 100644 --- a/src/PIL/ImageWin.py +++ b/src/PIL/ImageWin.py @@ -224,7 +224,7 @@ class ImageWindow(Window): image = Dib(image) self.image = image width, height = image.size - Window.__init__(self, title, width=width, height=height) + super().__init__(title, width=width, height=height) def ui_handle_repair(self, dc, x0, y0, x1, y1): self.image.draw(dc, (x0, y0, x1, y1)) diff --git a/src/PIL/PcfFontFile.py b/src/PIL/PcfFontFile.py index 074124612..7b3075696 100644 --- a/src/PIL/PcfFontFile.py +++ b/src/PIL/PcfFontFile.py @@ -62,7 +62,7 @@ class PcfFontFile(FontFile.FontFile): if magic != PCF_MAGIC: raise SyntaxError("not a PCF file") - FontFile.FontFile.__init__(self) + super().__init__() count = l32(fp.read(4)) self.toc = {} diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index be237b3ee..84317ceb7 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -293,8 +293,7 @@ class PngInfo(object): class PngStream(ChunkStream): def __init__(self, fp): - - ChunkStream.__init__(self, fp) + super().__init__(fp) # local copies of Image attributes self.im_info = {} diff --git a/src/PIL/TarIO.py b/src/PIL/TarIO.py index e180b802c..92a08aefb 100644 --- a/src/PIL/TarIO.py +++ b/src/PIL/TarIO.py @@ -55,7 +55,7 @@ class TarIO(ContainerIO.ContainerIO): self.fh.seek((size + 511) & (~511), io.SEEK_CUR) # Open region - ContainerIO.ContainerIO.__init__(self, self.fh, self.fh.tell(), size) + super().__init__(self.fh, self.fh.tell(), size) # Context manager support def __enter__(self): diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index b0d465fe2..455fbd0ee 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -911,7 +911,7 @@ class ImageFileDirectory_v1(ImageFileDirectory_v2): """ def __init__(self, *args, **kwargs): - ImageFileDirectory_v2.__init__(self, *args, **kwargs) + super().__init__(*args, **kwargs) self._legacy_api = True tags = property(lambda self: self._tags_v1)