Skip to content

Commit ef9e1b0

Browse files
authored
Merge pull request #121 from MightyCreak/pylint
More lint errors fixed
2 parents 27769ee + 62e45aa commit ef9e1b0

29 files changed

+146
-126
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Pylint
2424
uses: cclauss/GitHub-Action-for-pylint@master
2525
with:
26-
args: "pylint src/vcs/ src/dialogs.py src/preferences.py src/resources.py src/utils.py src/widgets.py"
26+
args: "apk add --no-cache gtk+3.0-dev gobject-introspection-dev ; pip install -r requirements.txt ; pylint src/**/*.py"
2727

2828
meson-build-test:
2929
runs-on: ubuntu-latest

.pylintrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ignore=CVS
2424

2525
# Add files or directories matching the regex patterns to the ignore-list. The
2626
# regex matches against paths.
27-
ignore-paths=
27+
ignore-paths=src/diffuse/main.py
2828

2929
# Files or directories matching the regex patterns are skipped. The regex
3030
# matches against base names, not paths.
@@ -90,12 +90,10 @@ disable=raw-checker-failed,
9090
# temporary silenced messages (ordered alphabetically)
9191
duplicate-code,
9292
fixme,
93-
import-error,
9493
invalid-name,
9594
missing-class-docstring,
9695
missing-function-docstring,
9796
missing-module-docstring,
98-
no-self-use,
9997
too-few-public-methods,
10098
too-many-arguments,
10199
too-many-branches,

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- The new widgets.py is a bit fat though (~4000 lines)
1717

1818
### Fixed
19+
- The intense code cleaning seems to have fixed a bug with the `-c` argument
20+
(#120)
1921

2022
## [0.7.2] - 2021-11-18
2123

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyGObject~=3.40
2+
pylint~=2.11
File renamed without changes.

src/dialogs.py renamed to src/diffuse/dialogs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
from gi.repository import GObject, Gtk
2727
# pylint: enable=wrong-import-position
2828

29+
# pylint: disable-next=no-name-in-module
2930
from diffuse import constants
31+
3032
from diffuse import utils
3133

3234
# the about dialog
@@ -67,7 +69,8 @@ class FileChooserDialog(Gtk.FileChooserDialog):
6769
# location for empty panes
6870
last_chosen_folder = os.path.realpath(os.curdir)
6971

70-
def __current_folder_changed_cb(self, widget):
72+
@staticmethod
73+
def _current_folder_changed_cb(widget):
7174
FileChooserDialog.last_chosen_folder = widget.get_current_folder()
7275

7376
def __init__(self, title, parent, prefs, action, accept, rev=False):
@@ -96,7 +99,7 @@ def __init__(self, title, parent, prefs, action, accept, rev=False):
9699
self.vbox.pack_start(hbox, False, False, 0) # pylint: disable=no-member
97100
hbox.show()
98101
self.set_current_folder(self.last_chosen_folder)
99-
self.connect('current-folder-changed', self.__current_folder_changed_cb)
102+
self.connect('current-folder-changed', self._current_folder_changed_cb)
100103

101104
def set_encoding(self, encoding):
102105
self.encoding.set_text(encoding)
@@ -107,6 +110,7 @@ def get_encoding(self):
107110
def get_revision(self):
108111
return self.revision.get_text()
109112

113+
# pylint: disable-next=arguments-differ
110114
def get_filename(self):
111115
# convert from UTF-8 string to unicode
112116
return Gtk.FileChooserDialog.get_filename(self) # pylint: disable=no-member
File renamed without changes.

src/main.py renamed to src/diffuse/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
import os
2121
import sys
2222
import codecs
23-
import difflib
2423
import encodings
2524
import shlex
2625
import stat
27-
import unicodedata
2826
import webbrowser
2927

3028
# pylint: disable=wrong-import-position
@@ -40,14 +38,16 @@
4038

4139
from urllib.parse import urlparse
4240

41+
# pylint: disable-next=no-name-in-module
4342
from diffuse import constants
43+
4444
from diffuse import utils
4545
from diffuse.dialogs import AboutDialog, FileChooserDialog, NumericDialog, SearchDialog
4646
from diffuse.preferences import Preferences
47-
from diffuse.resources import Resources, theResources
47+
from diffuse.resources import theResources
4848
from diffuse.vcs.vcs_registry import VcsRegistry
49-
from diffuse.widgets import FileDiffViewer, ScrolledWindow
50-
from diffuse.widgets import LINE_MODE, CHAR_MODE, ALIGN_MODE
49+
from diffuse.widgets import FileDiffViewer
50+
from diffuse.widgets import createMenu, LINE_MODE, CHAR_MODE, ALIGN_MODE
5151

5252
theVCSs = VcsRegistry()
5353

@@ -933,11 +933,11 @@ def saveState(self, statepath):
933933
utils.logDebug(f'Error writing {statepath}.')
934934

935935
# select viewer for a newly selected file in the confirm close dialogue
936-
def __confirmClose_row_activated_cb(self, tree, path, col, model):
936+
def _confirmClose_row_activated_cb(self, tree, path, col, model):
937937
self.notebook.set_current_page(self.notebook.page_num(model[path][3]))
938938

939939
# toggle save state for a file listed in the confirm close dialogue
940-
def __confirmClose_toggle_cb(self, cell, path, model):
940+
def _confirmClose_toggle_cb(self, cell, path, model):
941941
model[path][0] = not model[path][0]
942942

943943
# returns True if the list of viewers can be closed. The user will be
@@ -970,7 +970,7 @@ def confirmCloseViewers(self, viewers):
970970
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
971971
treeview = Gtk.TreeView.new_with_model(model)
972972
r = Gtk.CellRendererToggle.new()
973-
r.connect('toggled', self.__confirmClose_toggle_cb, model)
973+
r.connect('toggled', self._confirmClose_toggle_cb, model)
974974
column = Gtk.TreeViewColumn(None, r)
975975
column.add_attribute(r, 'active', 0)
976976
treeview.append_column(column)
@@ -984,7 +984,7 @@ def confirmCloseViewers(self, viewers):
984984
column.set_resizable(True)
985985
column.set_sort_column_id(2)
986986
treeview.append_column(column)
987-
treeview.connect('row-activated', self.__confirmClose_row_activated_cb, model)
987+
treeview.connect('row-activated', self._confirmClose_row_activated_cb, model)
988988
sw.add(treeview)
989989
treeview.show()
990990
dialog.vbox.pack_start(sw, True, True, 0) # pylint: disable=no-member
@@ -1190,7 +1190,7 @@ def createCommitFileTabs(self, items, labels, options):
11901190
new_items = []
11911191
for item in items:
11921192
name, data = item
1193-
# get full path to an existing ancessor directory
1193+
# get full path to an existing ancestor directory
11941194
dn = os.path.abspath(name)
11951195
while not os.path.isdir(dn):
11961196
dn, old_dn = os.path.dirname(dn), dn
@@ -1552,7 +1552,7 @@ def _create_menu_bar(specs, radio, accel_group):
15521552
menu_bar = Gtk.MenuBar.new()
15531553
for label, spec in specs:
15541554
menu = Gtk.MenuItem.new_with_mnemonic(label)
1555-
menu.set_submenu(utils.createMenu(spec, radio, accel_group))
1555+
menu.set_submenu(createMenu(spec, radio, accel_group))
15561556
menu.set_use_underline(True)
15571557
menu.show()
15581558
menu_bar.append(menu)

src/diffuse/meson.build

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
2+
moduledir = join_paths(pkgdatadir, 'diffuse')
3+
sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
4+
5+
python = import('python')
6+
7+
conf = configuration_data()
8+
conf.set('PYTHON', python.find_installation('python3').path())
9+
conf.set('pkgdatadir', pkgdatadir)
10+
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
11+
12+
configure_file(
13+
input: 'diffuse.in',
14+
output: 'diffuse',
15+
configuration: conf,
16+
install: true,
17+
install_dir: get_option('bindir')
18+
)
19+
20+
conf = configuration_data()
21+
conf.set('VERSION', meson.project_version())
22+
conf.set('sysconfigdir', sysconfdir)
23+
conf.set('log_print_output', get_option('log_print_output'))
24+
conf.set('log_print_stack', get_option('log_print_stack'))
25+
conf.set('use_flatpak', get_option('use_flatpak'))
26+
27+
configure_file(
28+
input: 'constants.py.in',
29+
output: 'constants.py',
30+
configuration: conf,
31+
install: true,
32+
install_dir: moduledir
33+
)
34+
35+
diffuse_sources = [
36+
'__init__.py',
37+
'dialogs.py',
38+
'main.py',
39+
'preferences.py',
40+
'resources.py',
41+
'utils.py',
42+
'widgets.py',
43+
]
44+
45+
install_data(diffuse_sources, install_dir: moduledir)
46+
install_subdir('vcs', install_dir: moduledir, strip_directory: false)

0 commit comments

Comments
 (0)