mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
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:
commit
84fed4d213
|
@ -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()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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":
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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],
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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 = {}
|
||||||
|
|
|
@ -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 = {}
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user