Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a9f68f

Browse files
committed
Switch to argumentless (py3) super().
1 parent 637b649 commit 9a9f68f

51 files changed

Lines changed: 246 additions & 318 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/api/radar_chart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ class RadarAxes(PolarAxes):
6060
draw_patch = patch_dict[frame]
6161

6262
def __init__(self, *args, **kwargs):
63-
super(RadarAxes, self).__init__(*args, **kwargs)
63+
super().__init__(*args, **kwargs)
6464
# rotate plot such that the first axis is at the top
6565
self.set_theta_zero_location('N')
6666

6767
def fill(self, *args, **kwargs):
6868
"""Override fill so that line is closed by default"""
6969
closed = kwargs.pop('closed', True)
70-
return super(RadarAxes, self).fill(closed=closed, *args, **kwargs)
70+
return super().fill(closed=closed, *args, **kwargs)
7171

7272
def plot(self, *args, **kwargs):
7373
"""Override plot so that line is closed by default"""
74-
lines = super(RadarAxes, self).plot(*args, **kwargs)
74+
lines = super().plot(*args, **kwargs)
7575
for line in lines:
7676
self._close_line(line)
7777

examples/api/skewt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def update_position(self, loc):
2828
# This ensures that the new value of the location is set before
2929
# any other updates take place
3030
self._loc = loc
31-
super(SkewXTick, self).update_position(loc)
31+
super().update_position(loc)
3232

3333
def _has_default_loc(self):
3434
return self.get_loc() is None

examples/misc/anchored_artists.py

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,18 @@
44
================
55
66
"""
7-
from matplotlib.patches import Rectangle, Ellipse
87

9-
from matplotlib.offsetbox import AnchoredOffsetbox, AuxTransformBox, VPacker,\
10-
TextArea, DrawingArea
8+
from matplotlib.patches import Rectangle, Ellipse
9+
from matplotlib.offsetbox import (
10+
AnchoredOffsetbox, AuxTransformBox, DrawingArea, TextArea, VPacker)
1111

1212

1313
class AnchoredText(AnchoredOffsetbox):
1414
def __init__(self, s, loc, pad=0.4, borderpad=0.5,
1515
prop=None, frameon=True):
16-
17-
self.txt = TextArea(s,
18-
minimumdescent=False)
19-
20-
super(AnchoredText, self).__init__(loc, pad=pad, borderpad=borderpad,
21-
child=self.txt,
22-
prop=prop,
23-
frameon=frameon)
16+
self.txt = TextArea(s, minimumdescent=False)
17+
super().__init__(loc, pad=pad, borderpad=borderpad,
18+
child=self.txt, prop=prop, frameon=frameon)
2419

2520

2621
class AnchoredSizeBar(AnchoredOffsetbox):
@@ -42,10 +37,8 @@ def __init__(self, transform, size, label, loc,
4237
align="center",
4338
pad=0, sep=sep)
4439

45-
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
46-
child=self._box,
47-
prop=prop,
48-
frameon=frameon)
40+
super().__init__(loc, pad=pad, borderpad=borderpad,
41+
child=self._box, prop=prop, frameon=frameon)
4942

5043

5144
class AnchoredEllipse(AnchoredOffsetbox):
@@ -59,24 +52,16 @@ def __init__(self, transform, width, height, angle, loc,
5952
self._box = AuxTransformBox(transform)
6053
self.ellipse = Ellipse((0, 0), width, height, angle)
6154
self._box.add_artist(self.ellipse)
62-
63-
AnchoredOffsetbox.__init__(self, loc, pad=pad, borderpad=borderpad,
64-
child=self._box,
65-
prop=prop,
66-
frameon=frameon)
55+
super().__init__(loc, pad=pad, borderpad=borderpad,
56+
child=self._box, prop=prop, frameon=frameon)
6757

6858

6959
class AnchoredDrawingArea(AnchoredOffsetbox):
7060
def __init__(self, width, height, xdescent, ydescent,
7161
loc, pad=0.4, borderpad=0.5, prop=None, frameon=True):
72-
7362
self.da = DrawingArea(width, height, xdescent, ydescent)
74-
75-
super(AnchoredDrawingArea, self).__init__(loc, pad=pad,
76-
borderpad=borderpad,
77-
child=self.da,
78-
prop=None,
79-
frameon=frameon)
63+
super().__init__(loc, pad=pad, borderpad=borderpad,
64+
child=self.da, prop=None, frameon=frameon)
8065

8166

8267
if __name__ == "__main__":

examples/user_interfaces/embedding_in_qt_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
class ApplicationWindow(QtWidgets.QMainWindow):
2828
def __init__(self):
29-
super(ApplicationWindow, self).__init__()
29+
super().__init__()
3030
self._main = QtWidgets.QWidget()
3131
self.setCentralWidget(self._main)
3232
layout = QtWidgets.QVBoxLayout(self._main)

examples/user_interfaces/embedding_webagg_sgskip.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,9 @@ def send_binary(self, blob):
214214

215215
def __init__(self, figure):
216216
self.figure = figure
217-
self.manager = new_figure_manager_given_figure(
218-
id(figure), figure)
217+
self.manager = new_figure_manager_given_figure(id(figure), figure)
219218

220-
super(MyApplication, self).__init__([
219+
super().__init__([
221220
# Static files for the CSS and JS
222221
(r'/_static/(.*)',
223222
tornado.web.StaticFileHandler,

examples/userdemo/custom_boxstyle02.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, pad=0.3):
2626
"""
2727

2828
self.pad = pad
29-
super(MyStyle, self).__init__()
29+
super().__init__()
3030

3131
def transmute(self, x0, y0, width, height, mutation_size):
3232
"""

lib/matplotlib/animation.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def isAvailable(cls):
586586
def __init__(self, *args, **kwargs):
587587
if kwargs.get("extra_args") is None:
588588
kwargs["extra_args"] = ()
589-
super(PillowWriter, self).__init__(*args, **kwargs)
589+
super().__init__(*args, **kwargs)
590590

591591
def setup(self, fig, outfile, dpi=None):
592592
self._frames = []
@@ -782,7 +782,7 @@ def isAvailable(cls):
782782
bin_path = cls.bin_path()
783783
if bin_path == "convert":
784784
cls._init_from_registry()
785-
return super(ImageMagickBase, cls).isAvailable()
785+
return super().isAvailable()
786786

787787
ImageMagickBase._init_from_registry()
788788

@@ -877,8 +877,7 @@ def __init__(self, fps=30, codec=None, bitrate=None, extra_args=None,
877877
self._saved_frames = []
878878
self._total_bytes = 0
879879
self._hit_limit = False
880-
super(HTMLWriter, self).__init__(fps, codec, bitrate,
881-
extra_args, metadata)
880+
super().__init__(fps, codec, bitrate, extra_args, metadata)
882881

883882
def setup(self, fig, outfile, dpi, frame_dir=None):
884883
root, ext = os.path.splitext(outfile)
@@ -894,8 +893,7 @@ def setup(self, fig, outfile, dpi, frame_dir=None):
894893
else:
895894
frame_prefix = None
896895

897-
super(HTMLWriter, self).setup(fig, outfile, dpi,
898-
frame_prefix, clear_temp=False)
896+
super().setup(fig, outfile, dpi, frame_prefix, clear_temp=False)
899897

900898
def grab_frame(self, **savefig_kwargs):
901899
if self.embed_frames:
@@ -919,7 +917,7 @@ def grab_frame(self, **savefig_kwargs):
919917
else:
920918
self._saved_frames.append(imgdata64)
921919
else:
922-
return super(HTMLWriter, self).grab_frame(**savefig_kwargs)
920+
return super().grab_frame(**savefig_kwargs)
923921

924922
def _run(self):
925923
# make a duck-typed subprocess stand in

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def __init__(self, fig, rect,
583583
def __getstate__(self):
584584
# The renderer should be re-created by the figure, and then cached at
585585
# that point.
586-
state = super(_AxesBase, self).__getstate__()
586+
state = super().__getstate__()
587587
state['_cachedRenderer'] = None
588588
state.pop('_layoutbox')
589589
state.pop('_poslayoutbox')

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def draw(self):
431431
self.figure.draw(self.renderer)
432432
# A GUI class may be need to update a window using this draw, so
433433
# don't forget to call the superclass.
434-
super(FigureCanvasAgg, self).draw()
434+
super().draw()
435435
finally:
436436
# if toolbar:
437437
# toolbar.set_cursor(toolbar._lastCursor)

lib/matplotlib/backends/backend_gtk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,8 @@ def __init__ (self,
771771
filetypes = [],
772772
default_filetype = None
773773
):
774-
super(FileChooserDialog, self).__init__(title, parent, action, buttons)
775-
super(FileChooserDialog, self).set_do_overwrite_confirmation(True)
774+
super().__init__(title, parent, action, buttons)
775+
super().set_do_overwrite_confirmation(True)
776776
self.set_default_response(gtk.RESPONSE_OK)
777777

778778
if not path:

0 commit comments

Comments
 (0)