diff --git a/.editorconfig b/.editorconfig index 7ecb681b..13779f4c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,8 @@ +# Editorconfig file for cross-platform configuration of editors. root=true -[*.ini] -indent_style=space -indent_size=4 - -[*.{yml,yaml}] -indent_style=space -indent_size=2 +[*.py] +max_line_length=99 [*.rst] indent_style=space diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..11433ee8 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/doc/conf.py b/doc/conf.py index e2a26f4d..56d03c72 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,17 +1,17 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# Streaming Media Service Webapp documentation build configuration file, created by -# sphinx-quickstart on Fri Dec 8 11:20:11 2017. +# Streaming Media Service Webapp documentation build configuration file, +# created by sphinx-quickstart on Fri Dec 8 11:20:11 2017. # -# This file is execfile()d with the current directory set to its -# containing dir. +# This file is execfile()d with the current directory set to its containing +# dir. # # Note that not all possible configuration values are present in this # autogenerated file. # -# All configuration values have a default; values that are commented out -# serve to show the default. +# All configuration values have a default; values that are commented out serve +# to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -139,7 +139,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'StreamingMediaServiceWebapp.tex', 'Streaming Media Service Webapp Documentation', + (master_doc, 'StreamingMediaServiceWebapp.tex', + 'Streaming Media Service Webapp Documentation', 'University of Cambridge Information Services', 'manual'), ] @@ -149,7 +150,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'streamingmediaservicewebapp', 'Streaming Media Service Webapp Documentation', + (master_doc, 'streamingmediaservicewebapp', + 'Streaming Media Service Webapp Documentation', [author], 1) ] @@ -160,10 +162,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'StreamingMediaServiceWebapp', 'Streaming Media Service Webapp Documentation', + (master_doc, 'StreamingMediaServiceWebapp', + 'Streaming Media Service Webapp Documentation', author, 'StreamingMediaServiceWebapp', 'One line description of project.', 'Miscellaneous'), ] - - - diff --git a/doc/developer.rst b/doc/developer.rst index 8660244d..2ff3d83a 100644 --- a/doc/developer.rst +++ b/doc/developer.rst @@ -171,6 +171,22 @@ pull request. Some items to note: using the PostgreSQL database and *not* sqlite. If you only run unit tests locally with sqlite then it is possible that some tests may fail. +Code-style +`````````` + +The ``tox`` test runner will automatically check the code with `flake8 +`_ to ensure PEP8 compliance. Sometimes, however, +rules are made to be broken and so you may find yourself needing to use the +`noqa in-line comment +`_ +mechanism to silence individual errors. + +To run the flake8 tests manually, specify the tox environment: + +.. code:: bash + + $ tox -e flake8 + Documentation ````````````` diff --git a/smswebapp/settings_developer.py b/smswebapp/settings_developer.py index b50833d3..92b3a945 100644 --- a/smswebapp/settings_developer.py +++ b/smswebapp/settings_developer.py @@ -1,5 +1,5 @@ # Import settings from the base settings file -from .settings import * +from .settings import * # noqa: F401, F403 # Use Demo Raven server UCAMWEBAUTH_LOGIN_URL = 'https://demo.raven.cam.ac.uk/auth/authenticate.html' diff --git a/smswebapp/settings_testsuite.py b/smswebapp/settings_testsuite.py index 8772d1a5..10cd025d 100644 --- a/smswebapp/settings_testsuite.py +++ b/smswebapp/settings_testsuite.py @@ -5,9 +5,9 @@ """ # Import settings from the base settings file -from .settings import * +from .settings import * # noqa: F401, F403 #: The default test runner is changed to one which captures stdout and stderr #: when running tests. -TEST_RUNNER='smswebapp.test.runner.BufferedDiscoverRunner' +TEST_RUNNER = 'smswebapp.test.runner.BufferedDiscoverRunner' diff --git a/smswebapp/test/runner.py b/smswebapp/test/runner.py index bc3f62ff..bdf12259 100644 --- a/smswebapp/test/runner.py +++ b/smswebapp/test/runner.py @@ -25,8 +25,8 @@ def __init__(self, stream=None, descriptions=True, verbosity=1, class BufferedDiscoverRunner(django.test.runner.DiscoverRunner): """ A sub-class of :py:class:`django.test.runner.DiscoverRunner` which has - exactly the same behaviour except that the :py:attr:`.test_runner` attribute - is set to :py:class:`.BufferedTextTestRunner`. + exactly the same behaviour except that the :py:attr:`.test_runner` + attribute is set to :py:class:`.BufferedTextTestRunner`. The upshot of this is that output to stdout and stderror is captured and only reported on test failure. diff --git a/tox.ini b/tox.ini index 22aef7db..7a5f8e8e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py36,doc +envlist=py36,doc,flake8 [testenv] # Additional dependencies @@ -24,3 +24,10 @@ commands= basepython=python3.6 deps=-rdoc/requirements.txt commands=sphinx-build -a -v -b html doc/ {toxinidir}/build/doc/ + +[testenv:flake8] +basepython=python3.6 +deps=flake8 +commands= + flake8 --version + flake8 smswebapp doc