← Back to team overview

openlp-core team mailing list archive

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

 

Simon Hanna has proposed merging lp:~thelinuxguy/openlp/flake-fixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~thelinuxguy/openlp/flake-fixes/+merge/353535

A couple of code fixes that I uncovered using linters
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~thelinuxguy/openlp/flake-fixes into lp:openlp.
=== modified file 'openlp/core/app.py'
--- openlp/core/app.py	2018-04-07 16:16:42 +0000
+++ openlp/core/app.py	2018-08-21 22:59:09 +0000
@@ -357,7 +357,7 @@
         portable_settings_path = data_path / 'OpenLP.ini'
         # Make this our settings file
         log.info('INI file: {name}'.format(name=portable_settings_path))
-        Settings.set_filename(str(portable_settings_path))
+        Settings.set_filename(portable_settings_path)
         portable_settings = Settings()
         # Set our data path
         log.info('Data path: {name}'.format(name=data_path))

=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2018-04-22 06:59:35 +0000
+++ openlp/core/lib/serviceitem.py	2018-08-21 22:59:09 +0000
@@ -39,7 +39,7 @@
 from openlp.core.common.mixins import RegistryProperties
 from openlp.core.common.path import Path
 from openlp.core.common.settings import Settings
-from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, expand_chords
+from openlp.core.lib import ImageSource, clean_tags, expand_tags, expand_chords
 
 log = logging.getLogger(__name__)
 

=== modified file 'openlp/core/projectors/editform.py'
--- openlp/core/projectors/editform.py	2018-04-21 19:57:51 +0000
+++ openlp/core/projectors/editform.py	2018-08-21 22:59:09 +0000
@@ -185,7 +185,6 @@
                                           translate('OpenLP.ProjectorEdit',
                                                     'You must enter a name for this entry.<br />'
                                                     'Please enter a new name for this entry.'))
-            valid = False
             return
         name = self.name_text.text().strip()
         record = self.projectordb.get_projector_by_name(name)
@@ -197,7 +196,6 @@
                                                     'the database as ID "{record}". <br />'
                                                     'Please enter a different name.'.format(name=name,
                                                                                             record=record.id)))
-            valid = False
             return
         if self.new_projector:
             # Only validate a new entry - otherwise it's been previously verified
@@ -223,7 +221,6 @@
                                               translate('OpenLP.ProjectorWizard',
                                                         'IP address "{ip}"<br>is not a valid IP address.'
                                                         '<br /><br />Please enter a valid IP address.'.format(ip=adx)))
-                valid = False
                 return
         port = int(self.port_text.text())
         if port < 1000 or port > 32767:

=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py	2018-08-04 20:58:13 +0000
+++ openlp/core/ui/advancedtab.py	2018-08-21 22:59:09 +0000
@@ -31,7 +31,7 @@
 from openlp.core.common.applocation import AppLocation
 from openlp.core.common.i18n import UiStrings, format_time, translate
 from openlp.core.common.settings import Settings
-from openlp.core.lib import SettingsTab, build_icon
+from openlp.core.lib import SettingsTab
 from openlp.core.ui.style import HAS_DARK_STYLE
 from openlp.core.ui.icons import UiIcons
 from openlp.core.widgets.edits import PathEdit

=== modified file 'openlp/core/ui/exceptiondialog.py'
--- openlp/core/ui/exceptiondialog.py	2018-06-10 19:29:00 +0000
+++ openlp/core/ui/exceptiondialog.py	2018-08-21 22:59:09 +0000
@@ -23,7 +23,7 @@
 The GUI widgets of the exception dialog.
 """
 
-from PyQt5 import QtGui, QtWidgets
+from PyQt5 import QtWidgets
 
 from openlp.core.common.i18n import translate
 from openlp.core.ui.icons import UiIcons

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2018-08-04 20:58:13 +0000
+++ openlp/core/ui/slidecontroller.py	2018-08-21 22:59:09 +0000
@@ -36,7 +36,7 @@
 from openlp.core.common.registry import Registry, RegistryBase
 from openlp.core.common.settings import Settings
 from openlp.core.display.screens import ScreenList
-from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, build_icon, build_html
+from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, build_html
 from openlp.core.lib.ui import create_action
 from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
 from openlp.core.ui.icons import UiIcons

=== modified file 'openlp/core/version.py'
--- openlp/core/version.py	2018-06-28 20:40:54 +0000
+++ openlp/core/version.py	2018-08-21 22:59:09 +0000
@@ -24,11 +24,8 @@
 """
 import logging
 import platform
-import sys
-import time
 from datetime import date
 from distutils.version import LooseVersion
-from subprocess import Popen, PIPE
 
 import requests
 from PyQt5 import QtCore

=== modified file 'openlp/core/widgets/edits.py'
--- openlp/core/widgets/edits.py	2018-04-21 05:59:03 +0000
+++ openlp/core/widgets/edits.py	2018-08-21 22:59:09 +0000
@@ -31,7 +31,7 @@
 from openlp.core.common.i18n import UiStrings, translate
 from openlp.core.common.path import Path, path_to_str, str_to_path
 from openlp.core.common.settings import Settings
-from openlp.core.lib import FormattingTags, build_icon
+from openlp.core.lib import FormattingTags
 from openlp.core.lib.ui import create_widget_action, create_action
 from openlp.core.ui.icons import UiIcons
 from openlp.core.widgets.dialogs import FileDialog

=== modified file 'openlp/core/widgets/wizard.py'
--- openlp/core/widgets/wizard.py	2018-06-03 16:07:20 +0000
+++ openlp/core/widgets/wizard.py	2018-08-21 22:59:09 +0000
@@ -32,7 +32,6 @@
 from openlp.core.common.mixins import RegistryProperties
 from openlp.core.common.registry import Registry
 from openlp.core.common.settings import Settings
-from openlp.core.lib import build_icon
 from openlp.core.lib.ui import add_welcome_page
 from openlp.core.widgets.dialogs import FileDialog
 

=== modified file 'openlp/plugins/alerts/endpoint.py'
--- openlp/plugins/alerts/endpoint.py	2017-12-29 09:15:48 +0000
+++ openlp/plugins/alerts/endpoint.py	2018-08-21 22:59:09 +0000
@@ -22,7 +22,6 @@
 import json
 import logging
 import urllib
-from urllib.parse import urlparse
 
 from openlp.core.api.http import requires_auth
 from openlp.core.api.http.endpoint import Endpoint

=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py	2018-04-10 19:26:56 +0000
+++ openlp/plugins/bibles/bibleplugin.py	2018-08-21 22:59:09 +0000
@@ -26,7 +26,7 @@
 from openlp.core.common.actions import ActionList
 from openlp.core.common.i18n import UiStrings, translate
 from openlp.core.ui.icons import UiIcons
-from openlp.core.lib import Plugin, StringContent, build_icon
+from openlp.core.lib import Plugin, StringContent
 from openlp.core.lib.ui import create_action
 from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint
 from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \

=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py	2017-12-29 09:15:48 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py	2018-08-21 22:59:09 +0000
@@ -31,7 +31,7 @@
 try:
     from pysword import modules
     PYSWORD_AVAILABLE = True
-except:
+except ImportError:
     PYSWORD_AVAILABLE = False
 
 from openlp.core.common import trace_error_handler
@@ -616,7 +616,7 @@
                                            (WebDownload.Bibleserver, BSExtract(proxy_server))):
             try:
                 bibles = extractor.get_bibles_from_http()
-            except (urllib.error.URLError, ConnectionError) as err:
+            except (urllib.error.URLError, ConnectionError):
                 critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Error during download'),
                                            translate('BiblesPlugin.ImportWizardForm',
                                                      'An error occurred while downloading the list of bibles from %s.'))

=== modified file 'openlp/plugins/bibles/lib/importers/csvbible.py'
--- openlp/plugins/bibles/lib/importers/csvbible.py	2017-12-29 09:15:48 +0000
+++ openlp/plugins/bibles/lib/importers/csvbible.py	2018-08-21 22:59:09 +0000
@@ -54,7 +54,6 @@
 
 from openlp.core.common import get_file_encoding
 from openlp.core.common.i18n import translate
-from openlp.core.common.path import Path
 from openlp.core.lib.exceptions import ValidationError
 from openlp.plugins.bibles.lib.bibleimport import BibleImport
 

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2018-04-22 07:17:38 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2018-08-21 22:59:09 +0000
@@ -21,7 +21,7 @@
 ###############################################################################
 import logging
 
-from PyQt5 import QtCore, QtGui, QtWidgets
+from PyQt5 import QtCore, QtWidgets
 
 from openlp.core.common.i18n import UiStrings, translate, get_natural_key
 from openlp.core.common.path import path_to_str, str_to_path

=== modified file 'openlp/plugins/songs/lib/importers/easyslides.py'
--- openlp/plugins/songs/lib/importers/easyslides.py	2018-07-02 20:38:47 +0000
+++ openlp/plugins/songs/lib/importers/easyslides.py	2018-08-21 22:59:09 +0000
@@ -107,7 +107,7 @@
     def _add_authors(self, writer):
         try:
             self.parse_author(str(writer))
-        except UnicodeDecodeError as e:
+        except UnicodeDecodeError:
             log.exception('Unicode decode error while decoding Writer')
             self._success = False
 

=== modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py'
--- tests/functional/openlp_plugins/bibles/test_csvimport.py	2017-12-29 09:15:48 +0000
+++ tests/functional/openlp_plugins/bibles/test_csvimport.py	2018-08-21 22:59:09 +0000
@@ -134,7 +134,7 @@
 
         with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
                    return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
-                patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True) as mocked_open,\
+                patch('openlp.core.common.path.Path.open', create=True) as mocked_open,\
                 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',
                       return_value=iter(test_data)) as mocked_reader:
 
@@ -154,7 +154,7 @@
         # GIVEN: Mocked a mocked open object which raises an OSError
         with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
                    return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
-                patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', side_effect=OSError, create=True):
+                patch('openlp.core.common.path.Path.open', side_effect=OSError, create=True):
 
             # WHEN: Calling CSVBible.parse_csv_file
             # THEN: A ValidationError should be raised
@@ -169,7 +169,7 @@
         # GIVEN: Mocked a csv.reader which raises an csv.Error
         with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
                    return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
-                patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True),\
+                patch('openlp.core.common.path.Path.open', create=True),\
                 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', side_effect=csv.Error):
 
             # WHEN: Calling CSVBible.parse_csv_file

=== modified file 'tests/openlp_core/projectors/test_projector_pjlink_commands_01.py'
--- tests/openlp_core/projectors/test_projector_pjlink_commands_01.py	2018-01-13 05:41:42 +0000
+++ tests/openlp_core/projectors/test_projector_pjlink_commands_01.py	2018-08-21 22:59:09 +0000
@@ -612,8 +612,8 @@
             # THEN: Power should be set to ON
             assert pjlink.power == S_STANDBY, 'Power should not have changed'
             assert mock_UpdateIcons.emit.called is False, 'projectorUpdateIcons() should not have been called'
-            mock_change_status.called is False, 'change_status() should not have been called'
-            mock_send_command.called is False, 'send_command() should not have been called'
+            assert mock_change_status.called is False, 'change_status() should not have been called'
+            assert mock_send_command.called is False, 'send_command() should not have been called'
             mock_log.warning.assert_has_calls(log_warn_calls)
 
     def test_projector_process_powr_off(self):
@@ -634,8 +634,8 @@
             # THEN: Power should be set to ON
             assert pjlink.power == S_STANDBY, 'Power should have changed to S_STANDBY'
             assert mock_UpdateIcons.emit.called is True, 'projectorUpdateIcons should have been called'
-            mock_change_status.called is True, 'change_status should have been called'
-            mock_send_command.called is False, 'send_command should not have been called'
+            assert mock_change_status.called is True, 'change_status should have been called'
+            assert mock_send_command.called is False, 'send_command should not have been called'
 
     def test_projector_process_rfil_save(self):
         """


Follow ups