8000 Fix some flake8 issues · matplotlib/matplotlib@b327b14 · GitHub
[go: up one dir, main page]

Skip to content

Commit b327b14

Browse files
committed
Fix some flake8 issues
1 parent 322757c commit b327b14

File tree

4 files changed

+76
-70
lines changed

4 files changed

+76
-70
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ per-file-ignores =
3131
matplotlib/_cm.py: E202, E203, E302
3232
matplotlib/_mathtext_data.py: E203, E261
3333
matplotlib/backend_bases.py: E225
34-
matplotlib/backends/_backend_tk.py: E203, E222, E225, E301, E401, E501
34+
matplotlib/backends/_backend_tk.py: E501
3535
matplotlib/backends/backend_agg.py: E302
3636
matplotlib/backends/backend_cairo.py: E203, E221, E402
3737
matplotlib/backends/backend_gtk3.py: E203, E221, E222, E225, E251, E501

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,8 +2886,8 @@ def release_zoom(self, event):
28862886
# ignore singular clicks - 5 pixels is a threshold
28872887
# allows the user to "cancel" a zoom action
28882888
# by zooming by less than 5 pixels
2889-
if ((abs(x - lastx) < 5 and self._zoom_mode!="y") or
2890-
(abs(y - lasty) < 5 and self._zoom_mode!="x")):
2889+
if ((abs(x - lastx) < 5 and self._zoom_mode != "y") or
2890+
(abs(y - lasty) < 5 and self._zoom_mode != "x")):
28912891
self._xypress = None
28922892
self.release(event)
28932893
self.draw()

lib/matplotlib/backends/_backend_tk.py

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -136,56 +136,56 @@ def _on_timer(self):
136136

137137

138138
class FigureCanvasTk(FigureCanvasBase):
139-
keyvald = {65507 : 'control',
140-
65505 : 'shift',
141-
65513 : 'alt',
142-
65515 : 'super',
143-
65508 : 'control',
144-
65506 : 'shift',
145-
65514 : 'alt',
146-
65361 : 'left',
147-
65362 : 'up',
148-
65363 : 'right',
149-
65364 : 'down',
150-
65307 : 'escape',
151-
65470 : 'f1',
152-
65471 : 'f2',
153-
65472 : 'f3',
154-
65473 : 'f4',
155-
65474 : 'f5',
156-
65475 : 'f6',
157-
65476 : 'f7',
158-
65477 : 'f8',
159-
65478 : 'f9',
160-
65479 : 'f10',
161-
65480 : 'f11',
162-
65481 : 'f12',
163-
65300 : 'scroll_lock',
164-
65299 : 'break',
165-
65288 : 'backspace',
166-
65293 : 'enter',
167-
65379 : 'insert',
168-
65535 : 'delete',
169-
65360 : 'home',
170-
65367 : 'end',
171-
65365 : 'pageup',
172-
65366 : 'pagedown',
173-
65438 : '0',
174-
65436 : '1',
175-
65433 : '2',
176-
65435 : '3',
177-
65430 : '4',
178-
65437 : '5',
179-
65432 : '6',
180-
65429 : '7',
181-
65431 : '8',
182-
65434 : '9',
183-
65451 : '+',
184-
65453 : '-',
185-
65450 : '*',
186-
65455 : '/',
187-
65439 : 'dec',
188-
65421 : 'enter',
139+
keyvald = {65507: 'control',
140+
65505: 'shift',
141+
65513: 'alt',
142+
65515: 'super',
143+
65508: 'control',
144+
65506: 'shift',
145+
65514: 'alt',
146+
65361: 'left',
147+
65362: 'up',
148+
65363: 'right',
149+
65364: 'down',
150+
65307: 'escape',
151+
65470: 'f1',
152+
65471: 'f2',
153+
65472: 'f3',
154+
65473: 'f4',
155+
65474: 'f5',
156+
65475: 'f6',
157+
65476: 'f7',
158+
65477: 'f8',
159+
65478: 'f9',
160+
65479: 'f10',
161+
65480: 'f11',
162+
65481: 'f12',
163+
65300: 'scroll_lock',
164+
65299: 'break',
165+
65288: 'backspace',
166+
65293: 'enter',
167+
65379: 'insert',
168+
65535: 'delete',
169+
65360: 'home',
170+
65367: 'end',
171+
65365: 'pageup',
172+
65366: 'pagedown',
173+
65438: '0',
174+
65436: '1',
175+
65433: '2',
176+
65435: '3',
177+
65430: '4',
178+
65437: '5',
179+
65432: '6',
180+
65429: '7',
181+
65431: '8',
182+
65434: '9',
183+
65451: '+',
184+
65453: '-',
185+
65450: '*',
186+
65455: '/',
187+
65439: 'dec',
188+
65421: 'enter',
189189
}
190190

191191
_keycode_lookup = {
@@ -407,12 +407,7 @@ def scroll_event(self, event):
407407
x = event.x
408408
y = self.figure.bbox.height - event.y
409409
num = getattr(event, 'num', None)
410-
if num == 4:
411-
step = +1
412-
elif num == 5:
413-
step = -1
414-
else:
415-
step = 0
410+
step = 1 if num == 4 else -1 if num == 5 else 0
416411
FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=event)
417412

418413
def scroll_event_windows(self, event):
@@ -462,7 +457,7 @@ def _get_key(self, event):
462457
]
463458

464459
if key is not None:
465-
# note, shift is not added to the keys as this is already accounted for
460+
# shift is not added to the keys as this is already accounted for
466461
for bitmask, prefix, key_name in modifiers:
467462
if event.state & (1 << bitmask) and key_name not in key:
468463
key = '{0}+{1}'.format(prefix, key)
@@ -479,7 +474,7 @@ def key_release(self, event):
479474

480475
def new_timer(self, *args, **kwargs):
481476
"""
482-
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
477+
Creates a new backend-specific subclass of `.backend_bases.Timer`.
483478
This is useful for getting periodic events through the backend's native
484479
event loop. Implemented only for backends with GUIs.
485480
@@ -518,9 +513,11 @@ def __init__(self, canvas, num, window):
518513
self.window.withdraw()
519514
self.set_window_title("Figure %d" % num)
520515
self.canvas = canvas
521-
# If using toolmanager it has to be present when initializing the toolbar
516+
# If using toolmanager it has to be present when initializing the
517+
# toolbar
522518
self.toolmanager = self._get_toolmanager()
523-
# packing toolbar first, because if space is getting low, last packed widget is getting shrunk first (-> the canvas)
519+
# packing toolbar first, because if space is getting low, last packed
520+
# widget is getting shrunk first (-> the canvas)
524521
self.toolbar = self._get_toolbar()
525522
self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
526523
self._num = num
@@ -582,7 +579,7 @@ def destroy(self, *args):
582579
if self.canvas._idle_callback:
583580
self.canvas._tkcanvas.after_cancel(self.canvas._idle_callback)
584581
self.window.destroy()
585-
if Gcf.get_num_fig_managers()==0:
582+
if Gcf.get_num_fig_managers() == 0:
586583
if self.window is not None:
587584
self.window.quit()
588585
self.window = None
@@ -650,7 +647,7 @@ def _Button(self, text, file, command, extension='.gif'):
650647
return b
651648

652649
def _Spacer(self):
653-
# Buttons are 30px high, so make this 26px tall with padding to center it
650+
# Buttons are 30px high. Make this 26px tall +2px padding to center it.
654651
s = Tk.Frame(
655652
master=self, height=26, relief=Tk.RIDGE, pady=2, bg="DarkGray")
656653
s.pack(side=Tk.LEFT, padx=5)
@@ -691,7 +688,9 @@ def configure_subplots(self):
691688
window.grab_set()
692689

693690
def save_figure(self, *args):
694-
import tkinter.filedialog, tkinter.messagebox
691+
import tkinter.filedialog
692+
import tkinter.messagebox
693+
695694
filetypes = self.canvas.get_supported_filetypes().copy()
696695
default_filetype = self.canvas.get_default_filetype()
697696

@@ -817,6 +816,7 @@ def set_cursor(self, cursor):
817816

818817
class ToolbarTk(ToolContainerBase, Tk.Frame):
819818
_icon_extension = '.gif'
819+
820820
def __init__(self, toolmanager, window):
821821
ToolContainerBase.__init__(self, toolmanager)
822822
xmin, xmax = self.toolmanager.canvas.figure.bbox.intervalx
@@ -911,7 +911,9 @@ def set_message(self, s):
911911

912912
class SaveFigureTk(backend_tools.SaveFigureBase):
913913
def trigger(self, *args):
914-
import tkinter.filedialog, tkinter.messagebox
914+
import tkinter.filedialog
915+
import tkinter.messagebox
916+
915917
filetypes = self.figure.canvas.get_supported_filetypes().copy()
916918
default_filetype = self.figure.canvas.get_default_filetype()
917919

lib/matplotlib/backends/qt_editor/formlayout.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def is_edit_valid(edit):
207207

208208
class FormWidget(QtWidgets.QWidget):
209209
update_buttons = QtCore.Signal()
210+
210211
def __init__(self, data, comment="", parent=None):
211212
QtWidgets.QWidget.__init__(self, parent)
212213
self.data = copy.deepcopy(data)
@@ -227,7 +228,8 @@ def setup(self):
227228
for label, value in self.data:
228229
if label is None and value is None:
229230
# Separator: (None, None)
230-
self.formlayout.addRow(QtWidgets.QLabel(" "), QtWidgets.QLabel(" "))
231+
self.formlayout.addRow(QtWidgets.QLabel(" "),
232+
QtWidgets.QLabel(" "))
231233
self.widgets.append(None)
232234
continue
233235
elif label is None:
@@ -341,7 +343,8 @@ def __init__(self, datalist, comment="", parent=None):
341343

342344
self.stackwidget = QtWidgets.QStackedWidget(self)
343345
layout.addWidget(self.stackwidget)
344-
self.combobox.currentIndexChanged.connect(self.stackwidget.setCurrentIndex)
346+
self.combobox.currentIndexChanged.connect(
347+
self.stackwidget.setCurrentIndex)
345348

346349
self.widgetlist = []
347350
for data, title, comment in datalist:
@@ -425,7 +428,8 @@ def __init__(self, data, title="", comment="",
425428

426429
self.setWindowTitle(title)
427430
if not isinstance(icon, QtGui.QIcon):
428-
icon = QtWidgets.QWidget().style().standardIcon(QtWidgets.QStyle.SP_MessageBoxQuestion)
431+
icon = QtWidgets.QWidget().style().standardIcon(
432+
QtWidgets.QStyle.SP_MessageBoxQuestion)
429433
self.setWindowIcon(icon)
430434

431435
def register_float_field(self, field):

0 commit comments

Comments
 (0)
0