Merge lp:~thelinuxguy/openlp/flake-fixes into lp:openlp

Proposed by Simon Hanna
Status: Needs review
Proposed branch: lp:~thelinuxguy/openlp/flake-fixes
Merge into: lp:openlp
Diff against target: 275 lines (+18/-27)
17 files modified
openlp/core/app.py (+1/-1)
openlp/core/lib/serviceitem.py (+1/-1)
openlp/core/projectors/editform.py (+0/-3)
openlp/core/ui/advancedtab.py (+1/-1)
openlp/core/ui/exceptiondialog.py (+1/-1)
openlp/core/ui/slidecontroller.py (+1/-1)
openlp/core/version.py (+0/-3)
openlp/core/widgets/edits.py (+1/-1)
openlp/core/widgets/wizard.py (+0/-1)
openlp/plugins/alerts/endpoint.py (+0/-1)
openlp/plugins/bibles/bibleplugin.py (+1/-1)
openlp/plugins/bibles/forms/bibleimportform.py (+2/-2)
openlp/plugins/bibles/lib/importers/csvbible.py (+0/-1)
openlp/plugins/presentations/lib/mediaitem.py (+1/-1)
openlp/plugins/songs/lib/importers/easyslides.py (+1/-1)
tests/functional/openlp_plugins/bibles/test_csvimport.py (+3/-3)
tests/openlp_core/projectors/test_projector_pjlink_commands_01.py (+4/-4)
To merge this branch: bzr merge lp:~thelinuxguy/openlp/flake-fixes
Reviewer Review Type Date Requested Status
Phill Needs Information
Review via email: mp+353535@code.launchpad.net

Description of the change

A couple of code fixes that I uncovered using linters

To post a comment you must log in.
Revision history for this message
Phill (phill-ridout) wrote :

I'm not sure about those patches that were changed (see in line) isn't patching supposed to take place in the module they're imported in to?

review: Needs Information
Revision history for this message
Simon Hanna (thelinuxguy) wrote :

I'm not sure if that makes a difference here, but when viewing it in the tests using the original definition shows what is actually being used. If you import it from somewhere else you could think that it's something different...

Unmerged revisions

2839. By Simon Hanna

Remove useless statements

2838. By Simon Hanna

Remove unused variable

2837. By Simon Hanna

Remove unused variable

2836. By Simon Hanna

Method expects Path and not str

2835. By Simon Hanna

Use proper Error in except clause

2834. By Simon Hanna

Add missing asserts

2833. By Simon Hanna

Fixup more hacks

2832. By Simon Hanna

Fix ugly hack in test

2831. By Simon Hanna

Remove unused imports

2830. By Simon Hanna

Remove unused import

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/app.py'
2--- openlp/core/app.py 2018-04-07 16:16:42 +0000
3+++ openlp/core/app.py 2018-08-21 22:59:09 +0000
4@@ -357,7 +357,7 @@
5 portable_settings_path = data_path / 'OpenLP.ini'
6 # Make this our settings file
7 log.info('INI file: {name}'.format(name=portable_settings_path))
8- Settings.set_filename(str(portable_settings_path))
9+ Settings.set_filename(portable_settings_path)
10 portable_settings = Settings()
11 # Set our data path
12 log.info('Data path: {name}'.format(name=data_path))
13
14=== modified file 'openlp/core/lib/serviceitem.py'
15--- openlp/core/lib/serviceitem.py 2018-04-22 06:59:35 +0000
16+++ openlp/core/lib/serviceitem.py 2018-08-21 22:59:09 +0000
17@@ -39,7 +39,7 @@
18 from openlp.core.common.mixins import RegistryProperties
19 from openlp.core.common.path import Path
20 from openlp.core.common.settings import Settings
21-from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, expand_chords
22+from openlp.core.lib import ImageSource, clean_tags, expand_tags, expand_chords
23
24 log = logging.getLogger(__name__)
25
26
27=== modified file 'openlp/core/projectors/editform.py'
28--- openlp/core/projectors/editform.py 2018-04-21 19:57:51 +0000
29+++ openlp/core/projectors/editform.py 2018-08-21 22:59:09 +0000
30@@ -185,7 +185,6 @@
31 translate('OpenLP.ProjectorEdit',
32 'You must enter a name for this entry.<br />'
33 'Please enter a new name for this entry.'))
34- valid = False
35 return
36 name = self.name_text.text().strip()
37 record = self.projectordb.get_projector_by_name(name)
38@@ -197,7 +196,6 @@
39 'the database as ID "{record}". <br />'
40 'Please enter a different name.'.format(name=name,
41 record=record.id)))
42- valid = False
43 return
44 if self.new_projector:
45 # Only validate a new entry - otherwise it's been previously verified
46@@ -223,7 +221,6 @@
47 translate('OpenLP.ProjectorWizard',
48 'IP address "{ip}"<br>is not a valid IP address.'
49 '<br /><br />Please enter a valid IP address.'.format(ip=adx)))
50- valid = False
51 return
52 port = int(self.port_text.text())
53 if port < 1000 or port > 32767:
54
55=== modified file 'openlp/core/ui/advancedtab.py'
56--- openlp/core/ui/advancedtab.py 2018-08-04 20:58:13 +0000
57+++ openlp/core/ui/advancedtab.py 2018-08-21 22:59:09 +0000
58@@ -31,7 +31,7 @@
59 from openlp.core.common.applocation import AppLocation
60 from openlp.core.common.i18n import UiStrings, format_time, translate
61 from openlp.core.common.settings import Settings
62-from openlp.core.lib import SettingsTab, build_icon
63+from openlp.core.lib import SettingsTab
64 from openlp.core.ui.style import HAS_DARK_STYLE
65 from openlp.core.ui.icons import UiIcons
66 from openlp.core.widgets.edits import PathEdit
67
68=== modified file 'openlp/core/ui/exceptiondialog.py'
69--- openlp/core/ui/exceptiondialog.py 2018-06-10 19:29:00 +0000
70+++ openlp/core/ui/exceptiondialog.py 2018-08-21 22:59:09 +0000
71@@ -23,7 +23,7 @@
72 The GUI widgets of the exception dialog.
73 """
74
75-from PyQt5 import QtGui, QtWidgets
76+from PyQt5 import QtWidgets
77
78 from openlp.core.common.i18n import translate
79 from openlp.core.ui.icons import UiIcons
80
81=== modified file 'openlp/core/ui/slidecontroller.py'
82--- openlp/core/ui/slidecontroller.py 2018-08-04 20:58:13 +0000
83+++ openlp/core/ui/slidecontroller.py 2018-08-21 22:59:09 +0000
84@@ -36,7 +36,7 @@
85 from openlp.core.common.registry import Registry, RegistryBase
86 from openlp.core.common.settings import Settings
87 from openlp.core.display.screens import ScreenList
88-from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, build_icon, build_html
89+from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, build_html
90 from openlp.core.lib.ui import create_action
91 from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
92 from openlp.core.ui.icons import UiIcons
93
94=== modified file 'openlp/core/version.py'
95--- openlp/core/version.py 2018-06-28 20:40:54 +0000
96+++ openlp/core/version.py 2018-08-21 22:59:09 +0000
97@@ -24,11 +24,8 @@
98 """
99 import logging
100 import platform
101-import sys
102-import time
103 from datetime import date
104 from distutils.version import LooseVersion
105-from subprocess import Popen, PIPE
106
107 import requests
108 from PyQt5 import QtCore
109
110=== modified file 'openlp/core/widgets/edits.py'
111--- openlp/core/widgets/edits.py 2018-04-21 05:59:03 +0000
112+++ openlp/core/widgets/edits.py 2018-08-21 22:59:09 +0000
113@@ -31,7 +31,7 @@
114 from openlp.core.common.i18n import UiStrings, translate
115 from openlp.core.common.path import Path, path_to_str, str_to_path
116 from openlp.core.common.settings import Settings
117-from openlp.core.lib import FormattingTags, build_icon
118+from openlp.core.lib import FormattingTags
119 from openlp.core.lib.ui import create_widget_action, create_action
120 from openlp.core.ui.icons import UiIcons
121 from openlp.core.widgets.dialogs import FileDialog
122
123=== modified file 'openlp/core/widgets/wizard.py'
124--- openlp/core/widgets/wizard.py 2018-06-03 16:07:20 +0000
125+++ openlp/core/widgets/wizard.py 2018-08-21 22:59:09 +0000
126@@ -32,7 +32,6 @@
127 from openlp.core.common.mixins import RegistryProperties
128 from openlp.core.common.registry import Registry
129 from openlp.core.common.settings import Settings
130-from openlp.core.lib import build_icon
131 from openlp.core.lib.ui import add_welcome_page
132 from openlp.core.widgets.dialogs import FileDialog
133
134
135=== modified file 'openlp/plugins/alerts/endpoint.py'
136--- openlp/plugins/alerts/endpoint.py 2017-12-29 09:15:48 +0000
137+++ openlp/plugins/alerts/endpoint.py 2018-08-21 22:59:09 +0000
138@@ -22,7 +22,6 @@
139 import json
140 import logging
141 import urllib
142-from urllib.parse import urlparse
143
144 from openlp.core.api.http import requires_auth
145 from openlp.core.api.http.endpoint import Endpoint
146
147=== modified file 'openlp/plugins/bibles/bibleplugin.py'
148--- openlp/plugins/bibles/bibleplugin.py 2018-04-10 19:26:56 +0000
149+++ openlp/plugins/bibles/bibleplugin.py 2018-08-21 22:59:09 +0000
150@@ -26,7 +26,7 @@
151 from openlp.core.common.actions import ActionList
152 from openlp.core.common.i18n import UiStrings, translate
153 from openlp.core.ui.icons import UiIcons
154-from openlp.core.lib import Plugin, StringContent, build_icon
155+from openlp.core.lib import Plugin, StringContent
156 from openlp.core.lib.ui import create_action
157 from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint
158 from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \
159
160=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
161--- openlp/plugins/bibles/forms/bibleimportform.py 2017-12-29 09:15:48 +0000
162+++ openlp/plugins/bibles/forms/bibleimportform.py 2018-08-21 22:59:09 +0000
163@@ -31,7 +31,7 @@
164 try:
165 from pysword import modules
166 PYSWORD_AVAILABLE = True
167-except:
168+except ImportError:
169 PYSWORD_AVAILABLE = False
170
171 from openlp.core.common import trace_error_handler
172@@ -616,7 +616,7 @@
173 (WebDownload.Bibleserver, BSExtract(proxy_server))):
174 try:
175 bibles = extractor.get_bibles_from_http()
176- except (urllib.error.URLError, ConnectionError) as err:
177+ except (urllib.error.URLError, ConnectionError):
178 critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Error during download'),
179 translate('BiblesPlugin.ImportWizardForm',
180 'An error occurred while downloading the list of bibles from %s.'))
181
182=== modified file 'openlp/plugins/bibles/lib/importers/csvbible.py'
183--- openlp/plugins/bibles/lib/importers/csvbible.py 2017-12-29 09:15:48 +0000
184+++ openlp/plugins/bibles/lib/importers/csvbible.py 2018-08-21 22:59:09 +0000
185@@ -54,7 +54,6 @@
186
187 from openlp.core.common import get_file_encoding
188 from openlp.core.common.i18n import translate
189-from openlp.core.common.path import Path
190 from openlp.core.lib.exceptions import ValidationError
191 from openlp.plugins.bibles.lib.bibleimport import BibleImport
192
193
194=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
195--- openlp/plugins/presentations/lib/mediaitem.py 2018-04-22 07:17:38 +0000
196+++ openlp/plugins/presentations/lib/mediaitem.py 2018-08-21 22:59:09 +0000
197@@ -21,7 +21,7 @@
198 ###############################################################################
199 import logging
200
201-from PyQt5 import QtCore, QtGui, QtWidgets
202+from PyQt5 import QtCore, QtWidgets
203
204 from openlp.core.common.i18n import UiStrings, translate, get_natural_key
205 from openlp.core.common.path import path_to_str, str_to_path
206
207=== modified file 'openlp/plugins/songs/lib/importers/easyslides.py'
208--- openlp/plugins/songs/lib/importers/easyslides.py 2018-07-02 20:38:47 +0000
209+++ openlp/plugins/songs/lib/importers/easyslides.py 2018-08-21 22:59:09 +0000
210@@ -107,7 +107,7 @@
211 def _add_authors(self, writer):
212 try:
213 self.parse_author(str(writer))
214- except UnicodeDecodeError as e:
215+ except UnicodeDecodeError:
216 log.exception('Unicode decode error while decoding Writer')
217 self._success = False
218
219
220=== modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py'
221--- tests/functional/openlp_plugins/bibles/test_csvimport.py 2017-12-29 09:15:48 +0000
222+++ tests/functional/openlp_plugins/bibles/test_csvimport.py 2018-08-21 22:59:09 +0000
223@@ -134,7 +134,7 @@
224
225 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
226 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
227- patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True) as mocked_open,\
228+ patch('openlp.core.common.path.Path.open', create=True) as mocked_open,\
229 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',
230 return_value=iter(test_data)) as mocked_reader:
231
232@@ -154,7 +154,7 @@
233 # GIVEN: Mocked a mocked open object which raises an OSError
234 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
235 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
236- patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', side_effect=OSError, create=True):
237+ patch('openlp.core.common.path.Path.open', side_effect=OSError, create=True):
238
239 # WHEN: Calling CSVBible.parse_csv_file
240 # THEN: A ValidationError should be raised
241@@ -169,7 +169,7 @@
242 # GIVEN: Mocked a csv.reader which raises an csv.Error
243 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
244 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
245- patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True),\
246+ patch('openlp.core.common.path.Path.open', create=True),\
247 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', side_effect=csv.Error):
248
249 # WHEN: Calling CSVBible.parse_csv_file
250
251=== modified file 'tests/openlp_core/projectors/test_projector_pjlink_commands_01.py'
252--- tests/openlp_core/projectors/test_projector_pjlink_commands_01.py 2018-01-13 05:41:42 +0000
253+++ tests/openlp_core/projectors/test_projector_pjlink_commands_01.py 2018-08-21 22:59:09 +0000
254@@ -612,8 +612,8 @@
255 # THEN: Power should be set to ON
256 assert pjlink.power == S_STANDBY, 'Power should not have changed'
257 assert mock_UpdateIcons.emit.called is False, 'projectorUpdateIcons() should not have been called'
258- mock_change_status.called is False, 'change_status() should not have been called'
259- mock_send_command.called is False, 'send_command() should not have been called'
260+ assert mock_change_status.called is False, 'change_status() should not have been called'
261+ assert mock_send_command.called is False, 'send_command() should not have been called'
262 mock_log.warning.assert_has_calls(log_warn_calls)
263
264 def test_projector_process_powr_off(self):
265@@ -634,8 +634,8 @@
266 # THEN: Power should be set to ON
267 assert pjlink.power == S_STANDBY, 'Power should have changed to S_STANDBY'
268 assert mock_UpdateIcons.emit.called is True, 'projectorUpdateIcons should have been called'
269- mock_change_status.called is True, 'change_status should have been called'
270- mock_send_command.called is False, 'send_command should not have been called'
271+ assert mock_change_status.called is True, 'change_status should have been called'
272+ assert mock_send_command.called is False, 'send_command should not have been called'
273
274 def test_projector_process_rfil_save(self):
275 """