From 0636df149ac110465dec9c9b03892205b4e6cfbf Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Wed, 8 Aug 2018 10:19:19 +0700 Subject: [PATCH] Fix and add flake8. --- .travis.yml | 3 ++- Makefile | 10 +++++----- parameters/qt_widgets/group_parameter_widget.py | 3 ++- parameters/qt_widgets/parameter_container.py | 13 ------------- parameters/qt_widgets/test/main.py | 9 +++++---- parameters/unit.py | 4 ++-- 6 files changed, 16 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index df9f999..b053d32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ virtualenv: install: - sudo apt-get install -y git pylint pep8 python3-pyqt5 - pip install nose nose-exclude nosexcover pyflakes + - pip install --upgrade flake8 before_script: - echo "Build starting on " `date` @@ -25,7 +26,7 @@ before_script: script: - xvfb-run --server-args="-screen 0, 1024x768x24" nosetests -v --with-id --with-xcoverage --with-xunit --verbose --cover-package=. - - make pep8 + - make flake8 after_success: - pip install coveralls diff --git a/Makefile b/Makefile index d68e28c..6de8f63 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ PROJECT_NAME = PARAMETERS BUILD_DIRECTORY = ../build_$(PROJECT_NAME) -# Run pep8 style checking -#http://pypi.python.org/pypi/pep8 -pep8: +# Run flake8 style checking +flake8: @echo @echo "-----------" - @echo "PEP8 issues" + @echo "Flake8 issues" @echo "-----------" - @pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128,E402 . || true + @python3 -m flake8 --version + @python3 -m flake8 || true # Run entire test suite test_suite: diff --git a/parameters/qt_widgets/group_parameter_widget.py b/parameters/qt_widgets/group_parameter_widget.py index 44db85c..67750d9 100644 --- a/parameters/qt_widgets/group_parameter_widget.py +++ b/parameters/qt_widgets/group_parameter_widget.py @@ -50,7 +50,8 @@ def __init__(self, parameter, parent=None): self.main_layout.addLayout(self._group_layout) # Why are we doing imports here? TS - from parameters.qt_widgets.parameter_container import ParameterContainer + from parameters.qt_widgets.parameter_container import ( + ParameterContainer) self.param_container = ParameterContainer( parameters=self._parameter.value) diff --git a/parameters/qt_widgets/parameter_container.py b/parameters/qt_widgets/parameter_container.py index 77f0dd8..4257f18 100644 --- a/parameters/qt_widgets/parameter_container.py +++ b/parameters/qt_widgets/parameter_container.py @@ -11,7 +11,6 @@ QFrame, QHBoxLayout ) -from PyQt5.QtGui import QColor from parameters.parameter_exceptions import InvalidValidationException from parameters.qt_widgets.qt5_parameter_factory import Qt5ParameterFactory @@ -190,21 +189,9 @@ def setup_ui(self, must_scroll=True): self.qt5_parameter_factory.register_widget( extra_parameter[0], extra_parameter[1]) - color_odd = QColor(220, 220, 220) - color_even = QColor(192, 192, 192) - - i = 0 for parameter in parameters: parameter_widget = self.qt5_parameter_factory.get_widget(parameter) - if i % 2: - color = color_even - else: - color = color_odd - i += 1 parameter_widget.setAutoFillBackground(True) - # palette = parameter_widget.palette() - # palette.setColor(parameter_widget.backgroundRole(), color) - # parameter_widget.setPalette(palette) self.vertical_layout.addWidget(parameter_widget) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) diff --git a/parameters/qt_widgets/test/main.py b/parameters/qt_widgets/test/main.py index 6d9d906..64c66be 100644 --- a/parameters/qt_widgets/test/main.py +++ b/parameters/qt_widgets/test/main.py @@ -4,7 +4,8 @@ import sys from functools import partial -from PyQt5.QtWidgets import QApplication, QWidget, QGridLayout, QPushButton, QMessageBox +from PyQt5.QtWidgets import ( + QApplication, QWidget, QGridLayout, QPushButton, QMessageBox) from parameters.boolean_parameter import BooleanParameter from parameters.dict_parameter import DictParameter @@ -54,11 +55,11 @@ def validate_min_max(parent_container): if min_value > max_value: print('Not valid') + message = ('Your minimum value (%d) should be less than your ' + 'maximum value (%d)' % (min_value, max_value)) return { 'valid': False, - 'message': ( - 'Your minimum value (%d) should be less than your maximum ' - 'value (%d)' % (min_value, max_value)) + 'message': message } print('Valid') return {'valid': True, 'message': ''} diff --git a/parameters/unit.py b/parameters/unit.py index 2db957f..3feb0d7 100644 --- a/parameters/unit.py +++ b/parameters/unit.py @@ -180,8 +180,8 @@ def serialize(self): 'plural': self.plural, 'abbreviation': self.abbreviation, 'help_text': self.help_text, - 'description': self.description, - } + 'description': self.description + } def __str__(self): return self.name