Add flake8 to gitlib-ci - closes #58

And fix the rest of the flake8 errors.

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Nikolas Nyby 2019-07-24 23:59:37 -04:00 committed by Sunil Mohan Adapa
parent f81b1751ce
commit 5439084c84
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
63 changed files with 105 additions and 82 deletions

View File

@ -21,6 +21,7 @@ run-unit-tests:
- echo "tester:password" | chpasswd
- cp -r . /home/tester/plinth
- chown -R tester:tester /home/tester/plinth
- su -c "cd ~/plinth; python3 -m flake8 plinth" tester
- su -c "cd ~/plinth; py.test-3 --cov=plinth --cov-report=html --cov-report=term" tester
- cp -r /home/tester/plinth/htmlcov test-coverage-report

View File

@ -26,5 +26,4 @@ class AppConfig(apps.AppConfig):
def ready(self):
# Signals must be loaded for axes to get the login_failed signals
# flake8: noqa
from axes import signals # isort:skip pylint: disable=unused-import
from axes import signals # noqa pylint: disable=unused-import isort:skip

View File

@ -69,8 +69,8 @@ class Uwsgi(app.LeaderComponent):
component_id should be a unique ID across all components of an app and
across all components.
uwsgi_name is the primary part of the configuration file path which must
be enabled/disabled by this component.
uwsgi_name is the primary part of the configuration file path
which must be enabled/disabled by this component.
"""
super().__init__(component_id)

View File

@ -28,7 +28,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from plinth.views import AppView
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
# pylint: disable=C0103

View File

@ -29,7 +29,7 @@ from plinth.daemon import Daemon
from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -31,7 +31,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.signals import domain_added, domain_removed, domainname_change
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -113,7 +113,9 @@ def get_home_page():
def change_home_page(shortcut_id):
"""Change the FreedomBox's default redirect to URL of the shortcut specified."""
"""Change the FreedomBox's default redirect to URL of the shortcut
specified.
"""
if shortcut_id == 'plinth':
url = '/plinth/'
elif shortcut_id == 'apache-default':

View File

@ -62,11 +62,12 @@ class ConfigurationForm(forms.Form):
hostname = forms.CharField(
label=ugettext_lazy('Hostname'), help_text=format_lazy(
ugettext_lazy(
'Hostname is the local name by which other devices on the local '
'network can reach your {box_name}. It must start and end with '
'an alphabet or a digit and have as interior characters only '
'alphabets, digits and hyphens. Total length must be 63 '
'characters or less.'), box_name=ugettext_lazy(cfg.box_name)),
'Hostname is the local name by which other devices on the '
'local network can reach your {box_name}. It must start and '
'end with an alphabet or a digit and have as interior '
'characters only alphabets, digits and hyphens. Total '
'length must be 63 characters or less.'),
box_name=ugettext_lazy(cfg.box_name)),
validators=[
validators.RegexValidator(HOSTNAME_REGEX,
ugettext_lazy('Invalid hostname'))
@ -76,12 +77,13 @@ class ConfigurationForm(forms.Form):
label=ugettext_lazy('Domain Name'), help_text=format_lazy(
ugettext_lazy(
'Domain name is the global name by which other devices on the '
'Internet can reach your {box_name}. It must consist of labels '
'separated by dots. Each label must start and end with an '
'alphabet or a digit and have as interior characters only '
'alphabets, digits and hyphens. Length of each label must be 63 '
'characters or less. Total length of domain name must be 253 '
'characters or less.'), box_name=ugettext_lazy(cfg.box_name)),
'Internet can reach your {box_name}. It must consist of '
'labels separated by dots. Each label must start and end '
'with an alphabet or a digit and have as interior characters '
'only alphabets, digits and hyphens. Length of each label '
'must be 63 characters or less. Total length of domain name '
'must be 253 characters or less.'),
box_name=ugettext_lazy(cfg.box_name)),
required=False, validators=[
validators.RegexValidator(
r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$',

View File

@ -27,7 +27,7 @@ from plinth.daemon import Daemon
from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
clients = clients

View File

@ -26,7 +26,7 @@ from plinth import app as app_module
from plinth import menu
from plinth.daemon import Daemon
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 2

View File

@ -28,7 +28,7 @@ from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 2

View File

@ -24,7 +24,7 @@ from plinth import action_utils
from plinth import app as app_module
from plinth import menu
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -70,7 +70,7 @@ description = [
' federate with other diaspora* pods.')
]
from .manifest import clients # isort:skip
from .manifest import clients # noqa pylint:disable=E402 isort:skip
clients = clients
app = None

View File

@ -28,7 +28,7 @@ from plinth.modules.names import SERVICES
from plinth.signals import domain_added
from plinth.utils import format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -36,7 +36,7 @@ from plinth.signals import (domainname_change, post_hostname_change,
pre_hostname_change)
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 3

View File

@ -22,7 +22,7 @@ from django.contrib import messages
from django.utils.translation import ugettext as _
from plinth import actions
from plinth.modules import config, ejabberd
from plinth.modules import ejabberd
from plinth.views import AppView
from .forms import EjabberdForm

View File

@ -25,7 +25,7 @@ from plinth import app as app_module
from plinth import cfg, menu
from plinth.utils import Version, format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 2

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.modules.i2p.resources import FAVORITES
from plinth.modules.users import register_group
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -96,8 +96,11 @@ class TunnelEditor():
:rtype: basestring
"""
calced_prop_path = '/files{filepath}/tunnel.{idx}.{tunnel_prop}'.format(
idx=self.idx, tunnel_prop=tunnel_prop, filepath=self.conf_filename)
calced_prop_path = \
'/files{filepath}/tunnel.{idx}.{tunnel_prop}'.format(
idx=self.idx,
tunnel_prop=tunnel_prop,
filepath=self.conf_filename)
return calced_prop_path
def set_tunnel_prop(self, tunnel_prop, value):

View File

@ -104,6 +104,6 @@ class TorrentsView(ServiceBaseView):
service_path = '/i2p/i2psnark/'
service_description = [
_('I2P provides an application to download files anonymously in a '
'peer-to-peer network. Download files by adding torrents or create a '
'new torrent to share a file.'),
'peer-to-peer network. Download files by adding torrents or '
'create a new torrent to share a file.'),
]

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from plinth.views import AppView
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -27,7 +27,7 @@ from plinth import app as app_module
from plinth import frontpage, menu
from plinth.modules.firewall.components import Firewall
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -34,7 +34,7 @@ from plinth.signals import (domain_added, domain_removed, domainname_change,
from plinth.utils import format_lazy
from . import components
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 3

View File

@ -275,7 +275,9 @@ def test_on_certificate_obtained(superuser_run, component):
def test_on_certificate_obtained_with_all_domains(superuser_run, component):
"""Test that certificate obtained event handler works for app with all domains."""
"""Test that certificate obtained event handler works for app with
all domains.
"""
component._domains = '*'
component.on_certificate_obtained(['valid.example'],
'/etc/letsencrypt/live/valid.example/')
@ -286,7 +288,9 @@ def test_on_certificate_obtained_with_all_domains(superuser_run, component):
def test_on_certificate_obtained_irrelevant(superuser_run, component):
"""Test that certificate obtained event handler works with irrelevant domain."""
"""Test that certificate obtained event handler works with
irrelevant domain.
"""
component.on_certificate_obtained(
['irrelevant.example'], '/etc/letsencrypt/live/irrelevant.example/')
_assert_copy_certificate_called(component, superuser_run, {})
@ -313,7 +317,9 @@ def test_on_certificate_renewed(superuser_run, component):
def test_on_certificate_renewed_irrelevant(superuser_run, component):
"""Test that certificate renewed event handler works for irrelevant domains."""
"""Test that certificate renewed event handler works for
irrelevant domains.
"""
component.on_certificate_renewed(
['irrelevant.example'], '/etc/letsencrypt/live/irrelevant.example/')
_assert_copy_certificate_called(component, superuser_run, {})
@ -340,7 +346,9 @@ def test_on_certificate_revoked(superuser_run, component):
def test_on_certificate_revoked_irrelevant(superuser_run, component):
"""Test that certificate revoked event handler works for irrelevant domains."""
"""Test that certificate revoked event handler works for
irrelevant domains.
"""
component.on_certificate_revoked(
['irrelevant.example'], '/etc/letsencrypt/live/irrelevant.example/')
_assert_copy_certificate_called(component, superuser_run, {})
@ -367,7 +375,9 @@ def test_on_certificate_deleted(superuser_run, component):
def test_on_certificate_deleted_irrelevant(superuser_run, component):
"""Test that certificate deleted event handler works for irrelevant domains."""
"""Test that certificate deleted event handler works for
irrelevant domains.
"""
component.on_certificate_deleted(
['irrelevant.example'], '/etc/letsencrypt/live/irrelevant.example/')
_assert_copy_certificate_called(component, superuser_run, {})

View File

@ -27,7 +27,6 @@ from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.views.decorators.http import require_POST
from plinth import actions
from plinth.errors import ActionError
from plinth.modules import letsencrypt

View File

@ -34,7 +34,7 @@ from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from plinth.modules.letsencrypt.components import LetsEncrypt
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 5

View File

@ -27,7 +27,7 @@ from plinth.daemon import Daemon
from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 6

View File

@ -29,7 +29,7 @@ from plinth.daemon import Daemon
from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 2

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -23,7 +23,7 @@ from django.utils.translation import ugettext_lazy as _
from plinth import app as app_module
from plinth import menu
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -28,7 +28,7 @@ from plinth.daemon import Daemon
from plinth.modules.firewall.components import Firewall
from plinth.views import AppView
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -27,7 +27,7 @@ from plinth import cfg, menu
from plinth.signals import domain_added, domain_removed
from plinth.utils import format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
SERVICES = (
('http', _('HTTP'), 80),

View File

@ -28,7 +28,7 @@ from plinth.daemon import Daemon
from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 3

View File

@ -25,7 +25,7 @@ from plinth import cfg, menu
from plinth.utils import format_lazy
from . import utils
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -47,6 +47,7 @@ _tests = [
},
]
def test_convert_service_to_string():
""" Test deconstructing parameter dictionaries into strings """
for test in _tests:

View File

@ -20,7 +20,7 @@ FreedomBox app for power controls.
from django.utils.translation import ugettext_lazy as _
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from plinth.views import AppView
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from plinth.views import AppView
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -34,7 +34,7 @@ from plinth.modules.apache.components import Uwsgi, Webserver
from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 2

View File

@ -77,7 +77,8 @@ clients = validate([{
'usage':
_('In Evolution add a new calendar and address book '
'respectively with WebDAV. Enter the URL of the Radicale '
'server (e.g. https://<your.freedombox.address>) and your user name. '
'server (e.g. https://<your.freedombox.address>) and your '
'user name. '
'Clicking on the search button will list the existing '
'calendars and address books.'),
'platforms': [{

View File

@ -29,7 +29,7 @@ from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from plinth.views import AppView
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 2

View File

@ -26,7 +26,7 @@ from plinth import frontpage, menu
from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1

View File

@ -29,7 +29,7 @@ from plinth.modules.apache.components import Uwsgi, Webserver
from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from .manifest import PUBLIC_ACCESS_SETTING_FILE, backup, clients
from .manifest import PUBLIC_ACCESS_SETTING_FILE, backup, clients # noqa, pylint: disable=unused-import
clients = clients

View File

@ -24,7 +24,7 @@ from plinth import actions
from plinth import app as app_module
from plinth import menu
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 6

View File

@ -33,6 +33,6 @@ class SecurityForm(forms.Form):
'without further authorization.'))
fail2ban_enabled = forms.BooleanField(
label=_('Fail2Ban (recommended)'), required=False,
help_text=_('When this option is enabled, Fail2Ban will limit brute force '
'break-in attempts to the SSH server and other enabled '
'password protected internet-services.'))
help_text=_('When this option is enabled, Fail2Ban will limit '
'brute force break-in attempts to the SSH server and '
'other enabled password protected internet-services.'))

View File

@ -28,7 +28,7 @@ from plinth.daemon import Daemon
from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -27,7 +27,7 @@ from plinth import app as app_module
from plinth import cfg, menu
from plinth.utils import format_lazy
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -75,5 +75,5 @@ class AddShareForm(forms.Form):
groups = self.cleaned_data.get('groups')
if not is_public and not groups:
raise forms.ValidationError(
_('Shares should be either public or shared with at least one group'
))
_('Shares should be either public or shared with at '
'least one group'))

View File

@ -28,7 +28,7 @@ from plinth import app as app_module
from plinth import menu
from plinth.modules import storage
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 4

View File

@ -25,7 +25,8 @@ from . import views
urlpatterns = [
url(r'^sys/snapshot/$', views.index, name='index'),
url(r'^sys/snapshot/manage/$', views.manage, name='manage'),
url(r'^sys/snapshot/selected/delete$', views.delete_selected, name='delete-selected'),
url(r'^sys/snapshot/selected/delete$', views.delete_selected,
name='delete-selected'),
url(r'^sys/snapshot/(?P<number>\d+)/rollback$', views.rollback,
name='rollback'),
]

View File

@ -137,7 +137,8 @@ def update_configuration(request, old_status, new_status):
('free_space', 'FREE_LIMIT={}'),
]))
if old_status['enable_software_snapshots'] != new_status['enable_software_snapshots']:
if old_status['enable_software_snapshots'] != new_status[
'enable_software_snapshots']:
if new_status['enable_software_snapshots'] == 'yes':
actions.superuser_run('snapshot', ['disable-apt-snapshot', 'no'])
else:

View File

@ -27,7 +27,7 @@ from plinth.daemon import Daemon
from plinth.modules.firewall.components import Firewall
from plinth.views import AppView
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -18,7 +18,9 @@
Forms for the Single Sign On app of FreedomBox.
"""
from django.contrib.auth.forms import AuthenticationForm as DjangoAuthenticationForm
from django.contrib.auth.forms import (
AuthenticationForm as DjangoAuthenticationForm
)
from captcha.fields import CaptchaField

View File

@ -23,7 +23,7 @@ import subprocess
import psutil
from django.utils.translation import ugettext_lazy as _
from plinth import action_utils, actions
from plinth import actions
from plinth import app as app_module
from plinth import cfg, menu, utils
from plinth.daemon import Daemon

View File

@ -29,7 +29,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from plinth.utils import format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 2

View File

@ -32,7 +32,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.utils import format_lazy
from .errors import TahoeConfigurationError
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -31,7 +31,7 @@ from plinth.modules.names import SERVICES
from plinth.signals import domain_added, domain_removed
from . import utils
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 3

View File

@ -30,7 +30,7 @@ from plinth.modules.apache.components import Webserver
from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 2

View File

@ -30,7 +30,7 @@ from plinth.modules.firewall.components import Firewall
from plinth.modules.users import register_group
from plinth.utils import Version, format_lazy
from .manifest import backup, clients
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 3

View File

@ -24,7 +24,7 @@ from plinth import actions
from plinth import app as app_module
from plinth import menu
from .manifest import backup
from .manifest import backup # noqa, pylint: disable=unused-import
version = 1

View File

@ -159,7 +159,8 @@ class UserDelete(ContextMixin, DeleteView):
messages.success(self.request, message)
try:
actions.superuser_run('users', ['remove-user', self.kwargs['slug']])
actions.superuser_run(
'users', ['remove-user', self.kwargs['slug']])
except ActionError:
messages.error(self.request,
_('Deleting LDAP user failed.'))

View File

@ -32,6 +32,6 @@ backups_ssh_repo_uuid = 'plinth_test_sshfs' # will be mounted to /media/<uuid>
# Import config_local to override the default variables
try:
from .config_local import *
from .config_local import * # noqa, pylint: disable=unused-import
except ImportError:
pass