pylint: enable import-error, no-name-in-module, no-self-use

This commit is contained in:
Romain Failliot 2021-11-21 14:15:22 -05:00
parent 032e9a398b
commit 5bcd63fe27
9 changed files with 38 additions and 24 deletions

View File

@ -90,13 +90,10 @@ disable=raw-checker-failed,
# temporary silenced messages (ordered alphabetically)
duplicate-code,
fixme,
import-error,
invalid-name,
missing-class-docstring,
missing-function-docstring,
missing-module-docstring,
no-name-in-module,
no-self-use,
too-few-public-methods,
too-many-arguments,
too-many-branches,

View File

@ -26,7 +26,9 @@ gi.require_version('Gtk', '3.0')
from gi.repository import GObject, Gtk
# pylint: enable=wrong-import-position
# pylint: disable-next=no-name-in-module
from diffuse import constants
from diffuse import utils
# the about dialog
@ -67,7 +69,8 @@ class FileChooserDialog(Gtk.FileChooserDialog):
# location for empty panes
last_chosen_folder = os.path.realpath(os.curdir)
def __current_folder_changed_cb(self, widget):
@staticmethod
def _current_folder_changed_cb(widget):
FileChooserDialog.last_chosen_folder = widget.get_current_folder()
def __init__(self, title, parent, prefs, action, accept, rev=False):
@ -96,7 +99,7 @@ class FileChooserDialog(Gtk.FileChooserDialog):
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)
self.connect('current-folder-changed', self._current_folder_changed_cb)
def set_encoding(self, encoding):
self.encoding.set_text(encoding)

View File

@ -38,7 +38,9 @@ from gi.repository import GObject, Gtk, Gdk, GdkPixbuf, Pango, PangoCairo
from urllib.parse import urlparse
# pylint: disable-next=no-name-in-module
from diffuse import constants
from diffuse import utils
from diffuse.dialogs import AboutDialog, FileChooserDialog, NumericDialog, SearchDialog
from diffuse.preferences import Preferences
@ -931,11 +933,11 @@ class Diffuse(Gtk.Window):
utils.logDebug(f'Error writing {statepath}.')
# select viewer for a newly selected file in the confirm close dialogue
def __confirmClose_row_activated_cb(self, tree, path, col, model):
def _confirmClose_row_activated_cb(self, tree, path, col, model):
self.notebook.set_current_page(self.notebook.page_num(model[path][3]))
# toggle save state for a file listed in the confirm close dialogue
def __confirmClose_toggle_cb(self, cell, path, model):
def _confirmClose_toggle_cb(self, cell, path, model):
model[path][0] = not model[path][0]
# returns True if the list of viewers can be closed. The user will be
@ -968,7 +970,7 @@ class Diffuse(Gtk.Window):
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
treeview = Gtk.TreeView.new_with_model(model)
r = Gtk.CellRendererToggle.new()
r.connect('toggled', self.__confirmClose_toggle_cb, model)
r.connect('toggled', self._confirmClose_toggle_cb, model)
column = Gtk.TreeViewColumn(None, r)
column.add_attribute(r, 'active', 0)
treeview.append_column(column)
@ -982,7 +984,7 @@ class Diffuse(Gtk.Window):
column.set_resizable(True)
column.set_sort_column_id(2)
treeview.append_column(column)
treeview.connect('row-activated', self.__confirmClose_row_activated_cb, model)
treeview.connect('row-activated', self._confirmClose_row_activated_cb, model)
sw.add(treeview)
treeview.show()
dialog.vbox.pack_start(sw, True, True, 0) # pylint: disable=no-member

View File

@ -29,9 +29,11 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# pylint: enable=wrong-import-position
from diffuse import utils
# pylint: disable-next=no-name-in-module
from diffuse import constants
from diffuse import utils
# class to store preferences and construct a dialogue for manipulating them
class Preferences:
def __init__(self, path):

View File

@ -29,6 +29,7 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# pylint: enable=wrong-import-position
# pylint: disable-next=no-name-in-module
from diffuse import constants
# convenience class for displaying a message dialogue

View File

@ -60,7 +60,7 @@ class Rcs(VcsInterface):
return result
# simulate use of popen with xargs to read the output of a command
def _popen_xargs_readlines(self, dn, cmd, args, prefs, bash_pref):
def _popen_xargs_readlines(self, cmd, args, prefs, bash_pref):
# os.sysconf() is only available on Unix
if hasattr(os, 'sysconf'):
maxsize = os.sysconf('SC_ARG_MAX')
@ -85,7 +85,7 @@ class Rcs(VcsInterface):
s += len(args[i]) + 1
i += 1
if i == len(args) or not f:
ss.extend(utils.popenReadLines(dn, a, prefs, bash_pref))
ss.extend(utils.popenReadLines(self.root, a, prefs, bash_pref))
s, a = 0, []
return ss
@ -138,7 +138,7 @@ class Rcs(VcsInterface):
args = [ utils.safeRelativePath(self.root, k, prefs, 'rcs_cygwin') for k in r ]
# run command
r, k = {}, ''
for line in self._popen_xargs_readlines(self.root, cmd, args, prefs, 'rcs_bash'):
for line in self._popen_xargs_readlines(cmd, args, prefs, 'rcs_bash'):
# parse response
if line.startswith('Working file: '):
k = prefs.convertToNativePath(line[14:])

View File

@ -23,18 +23,22 @@ from diffuse import utils
from diffuse.vcs.svn import Svn
class Svk(Svn):
def _getVcs(self):
@staticmethod
def _getVcs():
return 'svk'
def _getURLPrefix(self):
@staticmethod
def _getURLPrefix():
return 'Depot Path: '
def _parseStatusLine(self, s):
@staticmethod
def _parseStatusLine(s):
if len(s) < 4 or s[0] not in 'ACDMR':
return '', ''
return s[0], s[4:]
def _getPreviousRevision(self, rev):
@staticmethod
def _getPreviousRevision(rev):
if rev is None:
return 'HEAD'
if rev.endswith('@'):

View File

@ -31,13 +31,16 @@ class Svn(VcsInterface):
VcsInterface.__init__(self, root)
self.url = None
def _getVcs(self):
@staticmethod
def _getVcs():
return 'svn'
def _getURLPrefix(self):
@staticmethod
def _getURLPrefix():
return 'URL: '
def _parseStatusLine(self, s):
@staticmethod
def _parseStatusLine(s):
if len(s) < 8 or s[0] not in 'ACDMR':
return '', ''
# subversion 1.6 adds a new column
@ -46,7 +49,8 @@ class Svn(VcsInterface):
k += 1
return s[0], s[k:]
def _getPreviousRevision(self, rev):
@staticmethod
def _getPreviousRevision(rev):
if rev is None:
return 'BASE'
m = int(rev)

View File

@ -1649,7 +1649,8 @@ class FileDiffViewer(Gtk.Grid):
# scroll vertically to current line
self._ensure_line_is_visible(current_line)
def __set_clipboard_text(self, clipboard, s):
@staticmethod
def _set_clipboard_text(clipboard, s):
# remove embedded nulls as the clipboard cannot handle them
Gtk.Clipboard.get(clipboard).set_text(s.replace('\0', ''), -1)
@ -1673,7 +1674,7 @@ class FileDiffViewer(Gtk.Grid):
self.selection_char = sj
if extend:
self.__set_clipboard_text(Gdk.SELECTION_PRIMARY, self.getSelectedText())
self._set_clipboard_text(Gdk.SELECTION_PRIMARY, self.getSelectedText())
self._cursor_position_changed(True)
self.emit('cursor_changed')
@ -2922,7 +2923,7 @@ class FileDiffViewer(Gtk.Grid):
# 'copy' action
def copy(self):
if self.mode in (LINE_MODE, CHAR_MODE):
self.__set_clipboard_text(Gdk.SELECTION_CLIPBOARD, self.getSelectedText())
self._set_clipboard_text(Gdk.SELECTION_CLIPBOARD, self.getSelectedText())
# 'cut' action
def cut(self):