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