Add tox configuration to enable PEP-8 checks, and fix various failures

- E126 continuation line over-indented for hanging indent
- E127 continuation line over-indented for visual indent
- E128 continuation line under-indented for visual indent
- E131 continuation line unaligned for hanging indent
- E265 block comment should start with '# '
- E272 multiple spaces before keyword
- E302 expected 2 blank lines, found <n>
- E712 comparison to False should be 'if cond is False:' or 'if not cond:'
- F401 '<name>' imported but unused

Change-Id: I2344cf2e8fd7910e72e9d8043423d25e43065ef2
This commit is contained in:
David Pursehouse 2015-11-05 13:38:56 +09:00
parent 0939be787c
commit fbb61e9c1d
18 changed files with 68 additions and 48 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc *.pyc
.DS_Store .DS_Store
bootstrap.py bootstrap.py
.tox

View File

@ -8,4 +8,3 @@
:copyright: 2007 by Armin Ronacher. :copyright: 2007 by Armin Ronacher.
:license: BSD :license: BSD
""" """
from lodgeit.application import make_app

View File

@ -9,6 +9,7 @@
:license: BSD :license: BSD
""" """
def get_controller(name): def get_controller(name):
cname, hname = name.split('/') cname, hname = name.split('/')
module = __import__('lodgeit.controllers.' + cname, None, None, ['']) module = __import__('lodgeit.controllers.' + cname, None, None, [''])

View File

@ -167,11 +167,12 @@ def highlight_multifile(code):
start, filename, lang = last start, filename, lang = last
section_code = _escaped_marker.sub('', code[start:pos]) section_code = _escaped_marker.sub('', code[start:pos])
if section_code: if section_code:
if filename:
filename_html = u'<p class="filename">%s</p>' % escape(filename)
else:
filename_html = u''
result.append(u'<div class="section">%s%s</div>' % ( result.append(u'<div class="section">%s%s</div>' % (
filename and u'<p class="filename">%s</p>' filename_html, highlight(section_code, lang)))
% escape(filename) or u'',
highlight(section_code, lang)
))
for match in _section_marker_re.finditer(code): for match in _section_marker_re.finditer(code):
start = match.start() start = match.start()

View File

@ -32,6 +32,8 @@ def exported(name, hidden=False):
_public_methods = None _public_methods = None
def get_public_methods(): def get_public_methods():
"""Returns the public methods.""" """Returns the public methods."""
global _public_methods global _public_methods

View File

@ -95,7 +95,7 @@ class Paste(db.Model):
user_hash=local.request.user_hash).all()] user_hash=local.request.user_hash).all()]
paste_list = Paste.query.filter(db.and_( paste_list = Paste.query.filter(db.and_(
Paste.parent_id.in_(ids), Paste.parent_id.in_(ids),
Paste.handled == False, Paste.handled is False,
)).order_by(Paste.paste_id.desc()).all() )).order_by(Paste.paste_id.desc()).all()
for paste in paste_list: for paste in paste_list:
paste.handled = True paste.handled = True

View File

@ -85,7 +85,6 @@ class Request(RequestBase):
lang = session.get('locale') lang = session.get('locale')
if lang is None: if lang is None:
lang = 'en' lang = 'en'
#lang = (self.accept_languages.best or 'en').split('-')[0]
self.locale = Locale.parse(lang) self.locale = Locale.parse(lang)
def set_language(self, lang): def set_language(self, lang):

2
test-requirements.txt Normal file
View File

@ -0,0 +1,2 @@
flake8

View File

@ -5,5 +5,5 @@ default+apiclient=wsgi
wsgi=wsgi wsgi=wsgi
[default+apiclient.wsgi] [default+apiclient.wsgi]
server-entry-point = tests.utilities:foo server-entry-point = tests.utilities.runner:foo
base_url = http://www.localhost:5001 base_url = http://www.localhost:5001

View File

@ -1 +0,0 @@
from .runner import foo

16
tox.ini Normal file
View File

@ -0,0 +1,16 @@
[tox]
minversion = 1.6
envlist = pep8
skipsdist = True
[testenv]
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
[testenv:pep8]
commands = flake8
[flake8]
show-source = true
max-line-length = 80
exclude = ENV,.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools