]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix nearly all flake8 warnings except long lines.
authorBen Darnell <ben@bendarnell.com>
Sun, 10 Apr 2016 19:53:45 +0000 (15:53 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 10 Apr 2016 19:53:45 +0000 (15:53 -0400)
13 files changed:
tornado/auth.py
tornado/concurrent.py
tornado/escape.py
tornado/http1connection.py
tornado/ioloop.py
tornado/locks.py
tornado/options.py
tornado/queues.py
tornado/test/ioloop_test.py
tornado/test/twisted_test.py
tornado/test/web_test.py
tornado/test/wsgi_test.py
tornado/web.py

index ee3db4e95dbd8add93b351894d26b9b2d1beb776..5b7657bcebabb8e477e2996700c39d9cdc922714 100644 (file)
@@ -288,7 +288,7 @@ class OpenIdMixin(object):
         if name:
             user["name"] = name
         elif name_parts:
-            user["name"] = u(" ").join(name_parts)
+            user["name"] = u" ".join(name_parts)
         elif email:
             user["name"] = email.split("@")[0]
         if email:
index 42ab08034edf44bdf75fa51f8da72fb4fc1c0082..05205f7374c7eb826b42245a3f03679e288c51d9 100644 (file)
@@ -505,8 +505,9 @@ def chain_future(a, b):
         assert future is a
         if b.done():
             return
-        if (isinstance(a, TracebackFuture) and isinstance(b, TracebackFuture)
-                and a.exc_info() is not None):
+        if (isinstance(a, TracebackFuture) and
+                isinstance(b, TracebackFuture) and
+                a.exc_info() is not None):
             b.set_exc_info(a.exc_info())
         elif a.exception() is not None:
             b.set_exception(a.exception())
index c8d06286771113945e14c6b17bff9348b8863e43..e6636f203831aca90b790fb3504826d5e47d7b0d 100644 (file)
@@ -24,7 +24,6 @@ from __future__ import absolute_import, division, print_function, with_statement
 
 import json
 import re
-import sys
 
 from tornado.util import PY3, unicode_type, basestring_type
 
index 7632214544446d0ac8dbfba6ac5d7639498b9371..b04cff1322b270df8aa8ab3da1766453aa97cdf6 100644 (file)
@@ -359,8 +359,8 @@ class HTTP1Connection(httputil.HTTPConnection):
                 'Transfer-Encoding' not in headers)
             # If a 1.0 client asked for keep-alive, add the header.
             if (self._request_start_line.version == 'HTTP/1.0' and
-                (self._request_headers.get('Connection', '').lower()
-                 == 'keep-alive')):
+                (self._request_headers.get('Connection', '').lower() ==
+                 'keep-alive')):
                 headers['Connection'] = 'Keep-Alive'
         if self._chunking_output:
             headers['Transfer-Encoding'] = 'chunked'
@@ -479,9 +479,9 @@ class HTTP1Connection(httputil.HTTPConnection):
             connection_header = connection_header.lower()
         if start_line.version == "HTTP/1.1":
             return connection_header != "close"
-        elif ("Content-Length" in headers
-              or headers.get("Transfer-Encoding", "").lower() == "chunked"
-              or getattr(start_line, 'method', None) in ("HEAD", "GET")):
+        elif ("Content-Length" in headers or
+              headers.get("Transfer-Encoding", "").lower() == "chunked" or
+              getattr(start_line, 'method', None) in ("HEAD", "GET")):
             # start_line may be a request or reponse start line; only
             # the former has a method attribute.
             return connection_header == "keep-alive"
index 04094c9661faf8803b4cd09fc0603fad1e977da5..0bcbd776001239189cf44c00d366352905a7aaed 100644 (file)
@@ -814,8 +814,8 @@ class PollIOLoop(IOLoop):
                             due_timeouts.append(heapq.heappop(self._timeouts))
                         else:
                             break
-                    if (self._cancellations > 512
-                            and self._cancellations > (len(self._timeouts) >> 1)):
+                    if (self._cancellations > 512 and
+                            self._cancellations > (len(self._timeouts) >> 1)):
                         # Clean up the timeout queue when it gets large and it's
                         # more than half cancellations.
                         self._cancellations = 0
index abf5eade85e6c03be750af4599c10f3758604353..d84a9a870d7485a2b0c6c56a48fa9f27ec90130b 100644 (file)
 
 from __future__ import absolute_import, division, print_function, with_statement
 
-__all__ = ['Condition', 'Event', 'Semaphore', 'BoundedSemaphore', 'Lock']
-
 import collections
 
 from tornado import gen, ioloop
 from tornado.concurrent import Future
 
+__all__ = ['Condition', 'Event', 'Semaphore', 'BoundedSemaphore', 'Lock']
+
 
 class _TimeoutGarbageCollector(object):
     """Base class for objects that periodically clean up timed-out waiters.
index 84e170bbda30344cde3ea22361999b9f1f6f4c3a..2fbb32ad02692458b6d267ea5266eed5ad7d31f0 100644 (file)
@@ -43,8 +43,8 @@ either::
 
 .. note:
 
-   When using tornado.options.parse_command_line or 
-   tornado.options.parse_config_file, the only options that are set are 
+   When using tornado.options.parse_command_line or
+   tornado.options.parse_config_file, the only options that are set are
    ones that were previously defined with tornado.options.define.
 
 Command line formats are what you would expect (``--myoption=myvalue``).
index 129b204e362cbfb6f8f3630767821d7cbb711e36..b8e9b56939c82be6e66970bad5334e46dda4f741 100644 (file)
@@ -14,8 +14,6 @@
 
 from __future__ import absolute_import, division, print_function, with_statement
 
-__all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty']
-
 import collections
 import heapq
 
@@ -23,6 +21,8 @@ from tornado import gen, ioloop
 from tornado.concurrent import Future
 from tornado.locks import Event
 
+__all__ = ['Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty']
+
 
 class QueueEmpty(Exception):
     """Raised by `.Queue.get_nowait` when the queue has no items."""
index 71b4ef873e389691c7c33c09e65ffd641127ce0d..faea4365c2cfb2f5a36e0ca5cf8fdb0297f8fb79 100644 (file)
@@ -375,6 +375,7 @@ class TestIOLoop(AsyncTestCase):
             self.io_loop.add_callback(namespace["callback"])
             with ExpectLog(app_log, "Exception in callback"):
                 self.wait()
+
     def test_spawn_callback(self):
         # An added callback runs in the test's stack_context, so will be
         # re-arised in wait().
index 22e8b33d05bb5fa8c60c21de1f86f7d4d7fc406e..f1df06a6a1ceff055348bbab2e1f5d8bc2599d26 100644 (file)
@@ -28,7 +28,17 @@ import tempfile
 import threading
 import warnings
 
-from tornado.util import PY3
+from tornado.escape import utf8
+from tornado import gen
+from tornado.httpclient import AsyncHTTPClient
+from tornado.httpserver import HTTPServer
+from tornado.ioloop import IOLoop
+from tornado.platform.auto import set_close_exec
+from tornado.platform.select import SelectIOLoop
+from tornado.testing import bind_unused_port
+from tornado.test.util import unittest
+from tornado.util import import_object, PY3
+from tornado.web import RequestHandler, Application
 
 try:
     import fcntl
@@ -59,17 +69,6 @@ if PY3:
 else:
     import thread
 
-from tornado.escape import utf8
-from tornado import gen
-from tornado.httpclient import AsyncHTTPClient
-from tornado.httpserver import HTTPServer
-from tornado.ioloop import IOLoop
-from tornado.platform.auto import set_close_exec
-from tornado.platform.select import SelectIOLoop
-from tornado.testing import bind_unused_port
-from tornado.test.util import unittest
-from tornado.util import import_object
-from tornado.web import RequestHandler, Application
 
 skipIfNoTwisted = unittest.skipUnless(have_twisted,
                                       "twisted module not present")
index fd4d137d8880a4b880724f663e2cc99a2050feda..49049ad8616f8683c6de8ebbf1c2a816d5441a51 100644 (file)
@@ -34,7 +34,9 @@ else:
 
 wsgi_safe_tests = []
 
-relpath = lambda *a: os.path.join(os.path.dirname(__file__), *a)
+
+def relpath(*a):
+    return os.path.join(os.path.dirname(__file__), *a)
 
 
 def wsgi_safe(cls):
@@ -2163,6 +2165,7 @@ class BaseStreamingRequestFlowControlTest(object):
 
     def test_flow_control_chunked_body(self):
         chunks = [b'abcd', b'efgh', b'ijkl']
+
         @gen.coroutine
         def body_producer(write):
             for i in chunks:
@@ -2627,8 +2630,8 @@ class FinishExceptionTest(SimpleHandlerTestCase):
                 raise Finish()
 
     def test_finish_exception(self):
-        for url in ['/', '/?finish_value=1']:
-            response = self.fetch(url)
+        for u in ['/', '/?finish_value=1']:
+            response = self.fetch(u)
             self.assertEqual(response.code, 401)
             self.assertEqual('Basic realm="something"',
                              response.headers.get('WWW-Authenticate'))
index 94ee884b7e347741c4e27a6cbc5774bde0c08fa7..125d42aae6a039090c9f80d39069f2cc6b7bbfd1 100644 (file)
@@ -7,6 +7,9 @@ from tornado.testing import AsyncHTTPTestCase
 from tornado.web import RequestHandler, Application
 from tornado.wsgi import WSGIApplication, WSGIContainer, WSGIAdapter
 
+from tornado.test import httpserver_test
+from tornado.test import web_test
+
 
 class WSGIContainerTest(AsyncHTTPTestCase):
     def wsgi_app(self, environ, start_response):
@@ -61,13 +64,10 @@ class WSGIApplicationTest(AsyncHTTPTestCase):
         data = json_decode(response.body)
         self.assertEqual(data, {})
 
-# This is kind of hacky, but run some of the HTTPServer tests through
-# WSGIContainer and WSGIApplication to make sure everything survives
-# repeated disassembly and reassembly.
-from tornado.test import httpserver_test
-from tornado.test import web_test
-
 
+# This is kind of hacky, but run some of the HTTPServer and web tests
+# through WSGIContainer and WSGIApplication to make sure everything
+# survives repeated disassembly and reassembly.
 class WSGIConnectionTest(httpserver_test.HTTPConnectionTest):
     def get_app(self):
         return WSGIContainer(validator(WSGIApplication(self.get_handlers())))
index 14cadf6968a66ab4d65b7933491103dcfffa1e69..54a369877dbb63cd1796aeb1ad48b90e6b002f6a 100644 (file)
@@ -1380,7 +1380,9 @@ class RequestHandler(object):
             match = True
         else:
             # Use a weak comparison when comparing entity-tags.
-            val = lambda x: x[2:] if x.startswith(b'W/') else x
+            def val(x):
+                return x[2:] if x.startswith(b'W/') else x
+
             for etag in etags:
                 if val(etag) == val(computed_etag):
                     match = True
@@ -1598,6 +1600,7 @@ def asynchronous(method):
             result = method(self, *args, **kwargs)
             if result is not None:
                 result = gen.convert_yielded(result)
+
                 # If @asynchronous is used with @gen.coroutine, (but
                 # not @gen.engine), we can automatically finish the
                 # request when the future resolves.  Additionally,