diff --git a/isso/compat.py b/isso/compat.py index c93270d..fd7b6cb 100644 --- a/isso/compat.py +++ b/isso/compat.py @@ -13,12 +13,14 @@ if not PY2K: buffer = memoryview filter, map, zip = filter, map, zip - def iteritems(dikt): return iter(dikt.items()) # noqa: E731 + def iteritems(dikt): + return iter(dikt.items()) # noqa: E731 from functools import reduce else: buffer = buffer from itertools import ifilter, imap, izip filter, map, zip = ifilter, imap, izip - def iteritems(dikt): return dikt.iteritems() # noqa: E731 + def iteritems(dikt): + return dikt.iteritems() # noqa: E731 reduce = reduce diff --git a/isso/config.py b/isso/config.py index 917641d..3012385 100644 --- a/isso/config.py +++ b/isso/config.py @@ -123,8 +123,9 @@ def new(options=None): def load(default, user=None): # return set of (section, option) - def setify(cp): return set((section, option) for section in cp.sections() - for option in cp.options(section)) + def setify(cp): + return set((section, option) for section in cp.sections() + for option in cp.options(section)) parser = new() parser.read(default) diff --git a/isso/core.py b/isso/core.py index 9992df9..2395e13 100644 --- a/isso/core.py +++ b/isso/core.py @@ -123,7 +123,8 @@ class uWSGIMixin(Mixin): timedelta = conf.getint("moderation", "purge-after") - def purge(signum): return self.db.comments.purge(timedelta) + def purge(signum): + return self.db.comments.purge(timedelta) uwsgi.register_signal(1, "", purge) uwsgi.add_timer(1, timedelta) diff --git a/isso/db/__init__.py b/isso/db/__init__.py index ecc7a44..96281ef 100644 --- a/isso/db/__init__.py +++ b/isso/db/__init__.py @@ -98,7 +98,8 @@ class SQLite3: # limit max. nesting level to 1 if self.version == 2: - def first(rv): return list(map(operator.itemgetter(0), rv)) + def first(rv): + return list(map(operator.itemgetter(0), rv)) with sqlite3.connect(self.path) as con: top = first(con.execute( diff --git a/isso/tests/fixtures.py b/isso/tests/fixtures.py index 303e8bb..4bcdcb1 100644 --- a/isso/tests/fixtures.py +++ b/isso/tests/fixtures.py @@ -37,7 +37,9 @@ class Dummy: pass -def curl(method, host, path): return Dummy() +def curl(method, host, path): + return Dummy() -def loads(data): return json.loads(data.decode('utf-8')) +def loads(data): + return json.loads(data.decode('utf-8')) diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index 3c13b43..1257677 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -119,7 +119,8 @@ class TestComments(unittest.TestCase): def testVerifyFields(self): - def verify(comment): return comments.API.verify(comment)[0] + def verify(comment): + return comments.API.verify(comment)[0] # text is missing self.assertFalse(verify({})) diff --git a/isso/tests/test_guard.py b/isso/tests/test_guard.py index 4bbb50e..cce8d92 100644 --- a/isso/tests/test_guard.py +++ b/isso/tests/test_guard.py @@ -97,7 +97,8 @@ class TestGuard(unittest.TestCase): def testSelfReply(self): - def payload(id): return json.dumps({"text": "...", "parent": id}) + def payload(id): + return json.dumps({"text": "...", "parent": id}) client = self.makeClient("127.0.0.1", self_reply=False) self.assertEqual(client.post( @@ -124,7 +125,8 @@ class TestGuard(unittest.TestCase): def testRequireEmail(self): - def payload(email): return json.dumps({"text": "...", "email": email}) + def payload(email): + return json.dumps({"text": "...", "email": email}) client = self.makeClient("127.0.0.1", ratelimit=4, require_email=False) client_strict = self.makeClient( @@ -144,8 +146,8 @@ class TestGuard(unittest.TestCase): def testRequireAuthor(self): - def payload(author): return json.dumps( - {"text": "...", "author": author}) + def payload(author): + return json.dumps({"text": "...", "author": author}) client = self.makeClient( "127.0.0.1", ratelimit=4, require_author=False) diff --git a/isso/tests/test_wsgi.py b/isso/tests/test_wsgi.py index 254b51e..d1f4ff1 100644 --- a/isso/tests/test_wsgi.py +++ b/isso/tests/test_wsgi.py @@ -10,10 +10,10 @@ class TestWSGIUtilities(unittest.TestCase): def test_urlsplit(self): examples = [ - ("http://example.tld/", ('example.tld', 80, False)), + ("http://example.tld/", ('example.tld', 80, False)), ("https://example.tld/", ('example.tld', 443, True)), - ("example.tld", ('example.tld', 80, False)), - ("example.tld:42", ('example.tld', 42, False)), + ("example.tld", ('example.tld', 80, False)), + ("example.tld:42", ('example.tld', 42, False)), ("https://example.tld:80/", ('example.tld', 80, True))] for (hostname, result) in examples: @@ -23,7 +23,7 @@ class TestWSGIUtilities(unittest.TestCase): examples = [ (("example.tld", 80, False), "http://example.tld"), - (("example.tld", 42, True), "https://example.tld:42"), + (("example.tld", 42, True), "https://example.tld:42"), (("example.tld", 443, True), "https://example.tld")] for (split, result) in examples: diff --git a/isso/views/comments.py b/isso/views/comments.py index 699d66b..0bf4e45 100644 --- a/isso/views/comments.py +++ b/isso/views/comments.py @@ -104,23 +104,23 @@ class API(object): ACCEPT = set(['text', 'author', 'website', 'email', 'parent', 'title', 'notification']) VIEWS = [ - ('fetch', ('GET', '/')), - ('new', ('POST', '/new')), - ('count', ('GET', '/count')), - ('counts', ('POST', '/count')), - ('feed', ('GET', '/feed')), - ('view', ('GET', '/id/')), - ('edit', ('PUT', '/id/')), - ('delete', ('DELETE', '/id/')), + ('fetch', ('GET', '/')), + ('new', ('POST', '/new')), + ('count', ('GET', '/count')), + ('counts', ('POST', '/count')), + ('feed', ('GET', '/feed')), + ('view', ('GET', '/id/')), + ('edit', ('PUT', '/id/')), + ('delete', ('DELETE', '/id/')), ('unsubscribe', ('GET', '/id//unsubscribe//')), - ('moderate', ('GET', '/id///')), - ('moderate', ('POST', '/id///')), - ('like', ('POST', '/id//like')), - ('dislike', ('POST', '/id//dislike')), - ('demo', ('GET', '/demo')), - ('preview', ('POST', '/preview')), - ('login', ('POST', '/login')), - ('admin', ('GET', '/admin')) + ('moderate', ('GET', '/id///')), + ('moderate', ('POST', '/id///')), + ('like', ('POST', '/id//like')), + ('dislike', ('POST', '/id//dislike')), + ('demo', ('GET', '/demo')), + ('preview', ('POST', '/preview')), + ('login', ('POST', '/login')), + ('admin', ('GET', '/admin')) ] def __init__(self, isso, hasher):