Skip to content

Commit 6a90c81

Browse files
authored
Merge pull request #125 from MightyCreak/flake8
Use Flake8 instead of PyLint + integrate MyPy
2 parents ef9e1b0 + d89ac05 commit 6a90c81

File tree

23 files changed

+545
-471
lines changed

23 files changed

+545
-471
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
builtins = _
3+
max-line-length = 100
4+
5+
# Temporary
6+
exclude = src/diffuse/main.py

.github/workflows/main.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v2
20-
with:
21-
fetch-depth: 0
20+
- uses: actions/setup-python@v2
21+
- run: sudo apt install libgirepository1.0-dev
22+
- run: pip install -r requirements.txt
2223

23-
- name: Pylint
24-
uses: cclauss/GitHub-Action-for-pylint@master
25-
with:
26-
args: "apk add --no-cache gtk+3.0-dev gobject-introspection-dev ; pip install -r requirements.txt ; pylint src/**/*.py"
24+
- name: Flake8
25+
run: flake8 src/
26+
27+
- name: MyPy
28+
run: mypy src/
2729

2830
meson-build-test:
2931
runs-on: ubuntu-latest
3032
steps:
3133
- uses: actions/checkout@v2
32-
with:
33-
fetch-depth: 0
34+
- uses: actions/setup-python@v2
3435

3536
- name: Install dependencies
3637
run: sudo apt-get -y install appstream appstream-util desktop-file-utils gettext
@@ -52,6 +53,7 @@ jobs:
5253
options: --privileged
5354
steps:
5455
- uses: actions/checkout@v2
56+
- uses: actions/setup-python@v2
5557
- name: Flatpak builder
5658
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3
5759
with:

.mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
warn_unused_ignores = True

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
PyGObject~=3.40
2-
pylint~=2.11
1+
flake8 ~= 3.8
2+
mypy ~= 0.910
3+
PyGObject ~= 3.40

src/diffuse/dialogs.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@
1919

2020
import os
2121

22-
# pylint: disable=wrong-import-position
23-
import gi
22+
from diffuse import constants # type: ignore
23+
from diffuse import utils
24+
25+
import gi # type: ignore
2426
gi.require_version('GObject', '2.0')
2527
gi.require_version('Gtk', '3.0')
26-
from gi.repository import GObject, Gtk
27-
# pylint: enable=wrong-import-position
28+
from gi.repository import GObject, Gtk # type: ignore # noqa: E402
2829

29-
# pylint: disable-next=no-name-in-module
30-
from diffuse import constants
31-
32-
from diffuse import utils
3330

3431
# the about dialog
3532
class AboutDialog(Gtk.AboutDialog):
@@ -41,8 +38,8 @@ def __init__(self):
4138
self.set_comments(_('Diffuse is a graphical tool for merging and comparing text files.'))
4239
self.set_copyright(constants.COPYRIGHT)
4340
self.set_website(constants.WEBSITE)
44-
self.set_authors([ 'Derrick Moser <[email protected]>',
45-
'Romain Failliot <[email protected]>' ])
41+
self.set_authors(['Derrick Moser <[email protected]>',
42+
'Romain Failliot <[email protected]>'])
4643
self.set_translator_credits(_('translator-credits'))
4744
license_text = [
4845
constants.APP_NAME + ' ' + constants.VERSION + '\n\n',
@@ -59,9 +56,10 @@ def __init__(self):
5956
6057
You should have received a copy of the GNU General Public License along
6158
with this program; if not, write to the Free Software Foundation, Inc.,
62-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.''') ]
59+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.''')]
6360
self.set_license(''.join(license_text))
6461

62+
6563
# custom dialogue for picking files with widgets for specifying the encoding
6664
# and revision
6765
class FileChooserDialog(Gtk.FileChooserDialog):
@@ -85,7 +83,7 @@ def __init__(self, title, parent, prefs, action, accept, rev=False):
8583
label.show()
8684
self.encoding = entry = utils.EncodingMenu(
8785
prefs,
88-
action in [ Gtk.FileChooserAction.OPEN, Gtk.FileChooserAction.SELECT_FOLDER ])
86+
action in [Gtk.FileChooserAction.OPEN, Gtk.FileChooserAction.SELECT_FOLDER])
8987
hbox.pack_start(entry, False, False, 5)
9088
entry.show()
9189
if rev:
@@ -96,7 +94,7 @@ def __init__(self, title, parent, prefs, action, accept, rev=False):
9694
hbox.pack_end(label, False, False, 0)
9795
label.show()
9896

99-
self.vbox.pack_start(hbox, False, False, 0) # pylint: disable=no-member
97+
self.vbox.pack_start(hbox, False, False, 0)
10098
hbox.show()
10199
self.set_current_folder(self.last_chosen_folder)
102100
self.connect('current-folder-changed', self._current_folder_changed_cb)
@@ -110,10 +108,10 @@ def get_encoding(self):
110108
def get_revision(self):
111109
return self.revision.get_text()
112110

113-
# pylint: disable-next=arguments-differ
114111
def get_filename(self):
115112
# convert from UTF-8 string to unicode
116-
return Gtk.FileChooserDialog.get_filename(self) # pylint: disable=no-member
113+
return Gtk.FileChooserDialog.get_filename(self)
114+
117115

118116
# dialogue used to search for text
119117
class NumericDialog(Gtk.Dialog):
@@ -138,12 +136,13 @@ def __init__(self, parent, title, text, val, lower, upper, step=1, page=0):
138136
vbox.pack_start(hbox, True, True, 0)
139137
hbox.show()
140138

141-
self.vbox.pack_start(vbox, False, False, 0) # pylint: disable=no-member
139+
self.vbox.pack_start(vbox, False, False, 0)
142140
vbox.show()
143141

144142
def button_cb(self, widget):
145143
self.response(Gtk.ResponseType.ACCEPT)
146144

145+
147146
# dialogue used to search for text
148147
class SearchDialog(Gtk.Dialog):
149148
def __init__(self, parent, pattern=None, history=None):
@@ -190,7 +189,7 @@ def __init__(self, parent, pattern=None, history=None):
190189
vbox.pack_start(button, False, False, 0)
191190
button.show()
192191

193-
self.vbox.pack_start(vbox, False, False, 0) # pylint: disable=no-member
192+
self.vbox.pack_start(vbox, False, False, 0)
194193
vbox.show()
195194

196195
# callback used when the Enter key is pressed

0 commit comments

Comments
 (0)