Use more Pythonic super().__init__() instead of calling parent… (#2198)

Use more Pythonic super().__init__() instead of calling parent class directly
This commit is contained in:
Hugo van Kemenade 2019-10-23 14:09:02 +03:00 committed by GitHub
commit 84fed4d213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 11 additions and 14 deletions

View File

@ -25,7 +25,7 @@ class PillowQtTestCase(object):
class PillowQPixmapTestCase(PillowQtTestCase): class PillowQPixmapTestCase(PillowQtTestCase):
def setUp(self): def setUp(self):
PillowQtTestCase.setUp(self) super().setUp()
try: try:
if ImageQt.qt_version == "5": if ImageQt.qt_version == "5":
from PyQt5.QtGui import QGuiApplication from PyQt5.QtGui import QGuiApplication
@ -37,7 +37,7 @@ class PillowQPixmapTestCase(PillowQtTestCase):
self.app = QGuiApplication([]) self.app = QGuiApplication([])
def tearDown(self): def tearDown(self):
PillowQtTestCase.tearDown(self) super().tearDown()
self.app.quit() self.app.quit()

View File

@ -85,8 +85,7 @@ def bdf_char(f):
class BdfFontFile(FontFile.FontFile): class BdfFontFile(FontFile.FontFile):
def __init__(self, fp): def __init__(self, fp):
super().__init__()
FontFile.FontFile.__init__(self)
s = fp.readline() s = fp.readline()
if s[:13] != b"STARTFONT 2.1": if s[:13] != b"STARTFONT 2.1":

View File

@ -78,7 +78,7 @@ class ImageFile(Image.Image):
"Base class for image file format handlers." "Base class for image file format handlers."
def __init__(self, fp=None, filename=None): def __init__(self, fp=None, filename=None):
Image.Image.__init__(self) super().__init__()
self._min_frame = 0 self._min_frame = 0

View File

@ -180,8 +180,7 @@ if qt_is_installed:
# buffer, so this buffer has to hang on for the life of the image. # buffer, so this buffer has to hang on for the life of the image.
# Fixes https://github.com/python-pillow/Pillow/issues/1370 # Fixes https://github.com/python-pillow/Pillow/issues/1370
self.__data = im_data["data"] self.__data = im_data["data"]
QImage.__init__( super().__init__(
self,
self.__data, self.__data,
im_data["im"].size[0], im_data["im"].size[0],
im_data["im"].size[1], im_data["im"].size[1],

View File

@ -296,7 +296,7 @@ def _show(image, title):
self.image = BitmapImage(im, foreground="white", master=master) self.image = BitmapImage(im, foreground="white", master=master)
else: else:
self.image = PhotoImage(im, master=master) 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: if not tkinter._default_root:
raise IOError("tkinter not initialized") raise IOError("tkinter not initialized")

View File

@ -224,7 +224,7 @@ class ImageWindow(Window):
image = Dib(image) image = Dib(image)
self.image = image self.image = image
width, height = image.size 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): def ui_handle_repair(self, dc, x0, y0, x1, y1):
self.image.draw(dc, (x0, y0, x1, y1)) self.image.draw(dc, (x0, y0, x1, y1))

View File

@ -62,7 +62,7 @@ class PcfFontFile(FontFile.FontFile):
if magic != PCF_MAGIC: if magic != PCF_MAGIC:
raise SyntaxError("not a PCF file") raise SyntaxError("not a PCF file")
FontFile.FontFile.__init__(self) super().__init__()
count = l32(fp.read(4)) count = l32(fp.read(4))
self.toc = {} self.toc = {}

View File

@ -293,8 +293,7 @@ class PngInfo(object):
class PngStream(ChunkStream): class PngStream(ChunkStream):
def __init__(self, fp): def __init__(self, fp):
super().__init__(fp)
ChunkStream.__init__(self, fp)
# local copies of Image attributes # local copies of Image attributes
self.im_info = {} self.im_info = {}

View File

@ -55,7 +55,7 @@ class TarIO(ContainerIO.ContainerIO):
self.fh.seek((size + 511) & (~511), io.SEEK_CUR) self.fh.seek((size + 511) & (~511), io.SEEK_CUR)
# Open region # Open region
ContainerIO.ContainerIO.__init__(self, self.fh, self.fh.tell(), size) super().__init__(self.fh, self.fh.tell(), size)
# Context manager support # Context manager support
def __enter__(self): def __enter__(self):

View File

@ -911,7 +911,7 @@ class ImageFileDirectory_v1(ImageFileDirectory_v2):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
ImageFileDirectory_v2.__init__(self, *args, **kwargs) super().__init__(*args, **kwargs)
self._legacy_api = True self._legacy_api = True
tags = property(lambda self: self._tags_v1) tags = property(lambda self: self._tags_v1)