Fix pylint errors and warnings

Had to silence errors with dynamic members in Gtk.Dialog.
This commit is contained in:
Romain Failliot 2020-07-01 16:37:45 -04:00
parent 5d90910f30
commit 59b27958bf
1 changed files with 17 additions and 25 deletions

View File

@ -996,7 +996,7 @@ class Preferences:
p, t = v
if widgets[p].get_active() == t:
widgets[k].set_sensitive(False)
dialog.vbox.add(w)
dialog.vbox.add(w) # pylint: disable=no-member
w.show()
accept = (dialog.run() == Gtk.ResponseType.OK)
@ -1050,7 +1050,6 @@ class Preferences:
label.show()
return notebook
else:
n = len(template) - 1
table = Gtk.Grid.new()
table.set_border_width(10)
for i, tpl in enumerate(template[1:]):
@ -1138,7 +1137,7 @@ class Preferences:
return str(s, encoding=encoding), encoding
except (UnicodeDecodeError, LookupError):
pass
return u''.join([ unichr(ord(c)) for c in s ]), None
return u''.join([ chr(ord(c)) for c in s ]), None
# cygwin and native applications can be used on windows, use this method
# to convert a path to the usual form expected on sys.platform
@ -2414,7 +2413,7 @@ class _Svn:
result = []
try:
prev = self._getPreviousRevision(rev)
except ValueError as e:
except ValueError:
logError(_('Error parsing revision %s.') % (rev, ))
return result
@ -3472,9 +3471,9 @@ class FileDiffViewer(Gtk.Grid):
if c == ' ':
if visible:
# show spaces using a centre-dot
result.append(u'\u00b7');
result.append(u'\u00b7')
else:
result.append(c);
result.append(c)
elif c == '\t':
width = tab_width - col % tab_width
if visible:
@ -3703,11 +3702,11 @@ class FileDiffViewer(Gtk.Grid):
self.data = (f, format, old_format)
def undo(self, viewer):
f, format, old_format = self.data
f, _, old_format = self.data
viewer.setFormat(f, old_format)
def redo(self, viewer):
f, format, old_format = self.data
f, format, _ = self.data
viewer.setFormat(f, format)
# sets the cached line ending style
@ -3751,11 +3750,11 @@ class FileDiffViewer(Gtk.Grid):
self.data = (f, i, old_is_modified, old_text, is_modified, text)
def undo(self, viewer):
f, i, old_is_modified, old_text, is_modified, text = self.data
f, i, old_is_modified, old_text, _, _ = self.data
viewer.updateLineText(f, i, old_is_modified, old_text)
def redo(self, viewer):
f, i, old_is_modified, old_text, is_modified, text = self.data
f, i, _, _, is_modified, text = self.data
viewer.updateLineText(f, i, is_modified, text)
def getMapFlags(self, f, i):
@ -3794,8 +3793,6 @@ class FileDiffViewer(Gtk.Grid):
pane.line_lengths = max(pane.line_lengths, self.digit_width * self.stringWidth(text))
self.updateSize(False)
y = int(self.vadj.get_value())
h = self.font_height
fs = []
if f > 0:
fs.append(f - 1)
@ -3927,11 +3924,11 @@ class FileDiffViewer(Gtk.Grid):
self.data = (old_blocks, blocks)
def undo(self, viewer):
old_blocks, blocks = self.data
old_blocks, _ = self.data
viewer.updateBlocks(old_blocks)
def redo(self, viewer):
old_blocks, blocks = self.data
_, blocks = self.data
viewer.updateBlocks(blocks)
# change how lines are cut into blocks for alignment
@ -4327,8 +4324,6 @@ class FileDiffViewer(Gtk.Grid):
s = self.getLineText(f, line1)
ss.append(s[col1:])
line1 += 1
# insert blank lines for more space if needed
npanes = len(self.panes)
# remove blank rows if possible
n_need = len(ss)
@ -4579,8 +4574,7 @@ class FileDiffViewer(Gtk.Grid):
# scroll to ensure the current cursor position is visible
def _ensure_cursor_is_visible(self):
f, i, j = self.current_pane, self.current_line, self.current_char
h = self.font_height
current_line = self.current_line
# find the cursor's horizontal range
lower = self._get_cursor_x_offset()
@ -4599,7 +4593,7 @@ class FileDiffViewer(Gtk.Grid):
hadj.set_value(upper - ps)
# scroll vertically to current line
self._ensure_line_is_visible(i)
self._ensure_line_is_visible(current_line)
def __set_clipboard_text(self, clipboard, s):
# remove embedded nulls as the clipboard cannot handle them
@ -4748,7 +4742,6 @@ class FileDiffViewer(Gtk.Grid):
n = len(text)
j = self._getPickedCharacter(text, x, False)
if j < n:
ss = self.expand(text[:n])
c = getCharacterClass(text[j])
k = j
while k > 0 and getCharacterClass(text[k - 1]) == c:
@ -6667,7 +6660,7 @@ class SearchDialog(Gtk.Dialog):
vbox.pack_start(button, False, False, 0)
button.show()
self.vbox.pack_start(vbox, False, False, 0)
self.vbox.pack_start(vbox, False, False, 0) # pylint: disable=no-member
vbox.show()
# callback used when the Enter key is pressed
@ -6712,7 +6705,7 @@ class FileChooserDialog(Gtk.FileChooserDialog):
hbox.pack_end(label, False, False, 0)
label.show()
self.vbox.pack_start(hbox, False, False, 0)
self.vbox.pack_start(hbox, False, False, 0) # pylint: disable=no-member
hbox.show()
self.set_current_folder(self.last_chosen_folder)
self.connect('current-folder-changed', self.__current_folder_changed_cb)
@ -6753,7 +6746,7 @@ class NumericDialog(Gtk.Dialog):
vbox.pack_start(hbox, True, True, 0)
hbox.show()
self.vbox.pack_start(vbox, False, False, 0)
self.vbox.pack_start(vbox, False, False, 0) # pylint: disable=no-member
vbox.show()
def button_cb(self, widget):
@ -7742,7 +7735,7 @@ class Diffuse(Gtk.Window):
treeview.connect('row-activated', self.__confirmClose_row_activated_cb, model)
sw.add(treeview)
treeview.show()
dialog.vbox.pack_start(sw, True, True, 0)
dialog.vbox.pack_start(sw, True, True, 0) # pylint: disable=no-member
sw.show()
# add custom set of action buttons
dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
@ -8023,7 +8016,6 @@ class Diffuse(Gtk.Window):
# callback for the open file menu item
def open_file_in_new_tab_cb(self, widget, data):
specs = None
dialog = FileChooserDialog(_('Open File In New Tab'), self.get_toplevel(), self.prefs, Gtk.FileChooserAction.OPEN, Gtk.STOCK_OPEN, True)
dialog.set_default_response(Gtk.ResponseType.OK)
accept = (dialog.run() == Gtk.ResponseType.OK)