From: Pierce Lopez Date: Mon, 1 Jan 2018 22:46:05 +0000 (-0500) Subject: style fix: wrap or ignore long lines in tornado lib sources X-Git-Tag: v5.0.0~20^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6682d58bf261bcaa0d0939e4fd50a496f10a32ec;p=thirdparty%2Ftornado.git style fix: wrap or ignore long lines in tornado lib sources excluding tests --- diff --git a/setup.py b/setup.py index f9254d931..7cea09991 100644 --- a/setup.py +++ b/setup.py @@ -177,7 +177,8 @@ setup( author_email="python-tornado@googlegroups.com", url="http://www.tornadoweb.org/", license="http://www.apache.org/licenses/LICENSE-2.0", - description="Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.", + description=("Tornado is a Python web framework and asynchronous networking library," + " originally developed at FriendFeed."), classifiers=[ 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 2', diff --git a/tornado/auth.py b/tornado/auth.py index ba774c742..b8d373a58 100644 --- a/tornado/auth.py +++ b/tornado/auth.py @@ -392,7 +392,8 @@ class OAuthMixin(object): "Missing OAuth request token cookie")) return self.clear_cookie("_oauth_request_token") - cookie_key, cookie_secret = [base64.b64decode(escape.utf8(i)) for i in request_cookie.split("|")] + cookie_key, cookie_secret = [ + base64.b64decode(escape.utf8(i)) for i in request_cookie.split("|")] if cookie_key != request_key: future.set_exception(AuthError( "Request token does not match cookie")) @@ -896,7 +897,7 @@ class GoogleOAuth2Mixin(OAuth2Mixin): .. testoutput:: :hide: - """ + """ # noqa: E501 http = self.get_auth_http_client() body = urllib_parse.urlencode({ "redirect_uri": redirect_uri, @@ -908,7 +909,9 @@ class GoogleOAuth2Mixin(OAuth2Mixin): http.fetch(self._OAUTH_ACCESS_TOKEN_URL, functools.partial(self._on_access_token, callback), - method="POST", headers={'Content-Type': 'application/x-www-form-urlencoded'}, body=body) + method="POST", + headers={'Content-Type': 'application/x-www-form-urlencoded'}, + body=body) def _on_access_token(self, future, response): """Callback function for the exchange to the access token.""" @@ -965,7 +968,8 @@ class FacebookGraphMixin(OAuth2Mixin): Tornado it will change from a string to an integer. * ``id``, ``name``, ``first_name``, ``last_name``, ``locale``, ``picture``, ``link``, plus any fields named in the ``extra_fields`` argument. These - fields are copied from the Facebook graph API `user object `_ + fields are copied from the Facebook graph API + `user object `_ .. versionchanged:: 4.5 The ``session_expires`` field was updated to support changes made to the diff --git a/tornado/escape.py b/tornado/escape.py index 2ca3fe3fe..7fa6853bb 100644 --- a/tornado/escape.py +++ b/tornado/escape.py @@ -274,7 +274,9 @@ def recursive_unicode(obj): # This regex should avoid those problems. # Use to_unicode instead of tornado.util.u - we don't want backslashes getting # processed as escapes. -_URL_RE = re.compile(to_unicode(r"""\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&|")*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&|")*\)))+)""")) +_URL_RE = re.compile(to_unicode( + r"""\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&|")*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&|")*\)))+)""" # noqa: E501 +)) def linkify(text, shorten=False, extra_params="", diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 38c506d1b..b28eb46fe 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -49,11 +49,14 @@ import time import traceback import math -from tornado.concurrent import Future, is_future, chain_future, future_set_exc_info, future_add_done_callback +from tornado.concurrent import Future, is_future, chain_future, future_set_exc_info, future_add_done_callback # noqa: E501 from tornado.log import app_log, gen_log from tornado.platform.auto import set_close_exec, Waker from tornado import stack_context -from tornado.util import PY3, Configurable, errno_from_exception, timedelta_to_seconds, TimeoutError, unicode_type, import_object +from tornado.util import ( + PY3, Configurable, errno_from_exception, timedelta_to_seconds, + TimeoutError, unicode_type, import_object, +) try: import signal diff --git a/tornado/iostream.py b/tornado/iostream.py index 2c334d2f4..fb89da089 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -66,7 +66,7 @@ _ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE, errno.ETIMEDOUT) if hasattr(errno, "WSAECONNRESET"): - _ERRNO_CONNRESET += (errno.WSAECONNRESET, errno.WSAECONNABORTED, errno.WSAETIMEDOUT) # type: ignore + _ERRNO_CONNRESET += (errno.WSAECONNRESET, errno.WSAECONNABORTED, errno.WSAETIMEDOUT) # type: ignore # noqa: E501 if sys.platform == 'darwin': # OSX appears to have a race condition that causes send(2) to return diff --git a/tornado/log.py b/tornado/log.py index 6b1e186c2..fc95a5f98 100644 --- a/tornado/log.py +++ b/tornado/log.py @@ -102,7 +102,8 @@ class LogFormatter(logging.Formatter): Added support for ``colorama``. Changed the constructor signature to be compatible with `logging.config.dictConfig`. """ - DEFAULT_FORMAT = '%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d]%(end_color)s %(message)s' + DEFAULT_FORMAT = \ + '%(color)s[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d]%(end_color)s %(message)s' DEFAULT_DATE_FORMAT = '%y%m%d %H:%M:%S' DEFAULT_COLORS = { logging.DEBUG: 4, # Blue diff --git a/tornado/platform/twisted.py b/tornado/platform/twisted.py index 43e447c13..d1ab2c795 100644 --- a/tornado/platform/twisted.py +++ b/tornado/platform/twisted.py @@ -32,7 +32,7 @@ import sys import twisted.internet.abstract # type: ignore from twisted.internet.defer import Deferred # type: ignore from twisted.internet.posixbase import PosixReactorBase # type: ignore -from twisted.internet.interfaces import IReactorFDSet, IDelayedCall, IReactorTime, IReadDescriptor, IWriteDescriptor # type: ignore +from twisted.internet.interfaces import IReactorFDSet, IDelayedCall, IReactorTime, IReadDescriptor, IWriteDescriptor # type: ignore # noqa: E501 from twisted.python import failure, log # type: ignore from twisted.internet import error # type: ignore import twisted.names.cache # type: ignore diff --git a/tornado/platform/windows.py b/tornado/platform/windows.py index e94a0cf13..412770065 100644 --- a/tornado/platform/windows.py +++ b/tornado/platform/windows.py @@ -8,7 +8,7 @@ import ctypes.wintypes # type: ignore # See: http://msdn.microsoft.com/en-us/library/ms724935(VS.85).aspx SetHandleInformation = ctypes.windll.kernel32.SetHandleInformation -SetHandleInformation.argtypes = (ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD) +SetHandleInformation.argtypes = (ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD) # noqa: E501 SetHandleInformation.restype = ctypes.wintypes.BOOL HANDLE_FLAG_INHERIT = 0x00000001 diff --git a/tornado/routing.py b/tornado/routing.py index d3f17803b..4a19ba57a 100644 --- a/tornado/routing.py +++ b/tornado/routing.py @@ -293,7 +293,8 @@ class RuleRouter(Router): ]) In the examples above, ``Target`` can be a nested `Router` instance, an instance of - `~.httputil.HTTPServerConnectionDelegate` or an old-style callable, accepting a request argument. + `~.httputil.HTTPServerConnectionDelegate` or an old-style callable, + accepting a request argument. :arg rules: a list of `Rule` instances or tuples of `Rule` constructor arguments. diff --git a/tornado/template.py b/tornado/template.py index 3b2fa3fee..0818178dc 100644 --- a/tornado/template.py +++ b/tornado/template.py @@ -260,9 +260,8 @@ class Template(object): :arg str template_string: the contents of the template file. :arg str name: the filename from which the template was loaded (used for error message). - :arg tornado.template.BaseLoader loader: the `~tornado.template.BaseLoader` responsible for this template, - used to resolve ``{% include %}`` and ``{% extend %}`` - directives. + :arg tornado.template.BaseLoader loader: the `~tornado.template.BaseLoader` responsible + for this template, used to resolve ``{% include %}`` and ``{% extend %}`` directives. :arg bool compress_whitespace: Deprecated since Tornado 4.3. Equivalent to ``whitespace="single"`` if true and ``whitespace="all"`` if false. diff --git a/tornado/testing.py b/tornado/testing.py index a0c836642..21d4d8875 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -301,7 +301,8 @@ class AsyncTestCase(unittest.TestCase): except Exception: self.__failure = sys.exc_info() self.stop() - self.__timeout = self.io_loop.add_timeout(self.io_loop.time() + timeout, timeout_func) + self.__timeout = self.io_loop.add_timeout(self.io_loop.time() + timeout, + timeout_func) while True: self.__running = True self.io_loop.start() @@ -440,7 +441,8 @@ class AsyncHTTPSTestCase(AsyncHTTPTestCase): By default includes a self-signed testing certificate. """ # Testing keys were generated with: - # openssl req -new -keyout tornado/test/test.key -out tornado/test/test.crt -nodes -days 3650 -x509 + # openssl req -new -keyout tornado/test/test.key \ + # -out tornado/test/test.crt -nodes -days 3650 -x509 module_dir = os.path.dirname(__file__) return dict( certfile=os.path.join(module_dir, 'test', 'test.crt'), diff --git a/tornado/web.py b/tornado/web.py index 8827209c1..91d9abd1c 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -733,7 +733,8 @@ class RequestHandler(object): if not isinstance(chunk, (bytes, unicode_type, dict)): message = "write() only accepts bytes, unicode, and dict objects" if isinstance(chunk, list): - message += ". Lists not accepted for security reasons; see http://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.write" + message += ". Lists not accepted for security reasons; see " + \ + "http://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.write" raise TypeError(message) if isinstance(chunk, dict): chunk = escape.json_encode(chunk) @@ -1735,7 +1736,7 @@ def stream_request_body(cls): See the `file receiver demo `_ for example usage. - """ + """ # noqa: E501 if not issubclass(cls, RequestHandler): raise TypeError("expected subclass of RequestHandler, got %r", cls) cls._stream_request_body = True @@ -2818,7 +2819,7 @@ class OutputTransform(object): pass def transform_first_chunk(self, status_code, headers, chunk, finishing): - # type: (int, httputil.HTTPHeaders, bytes, bool) -> typing.Tuple[int, httputil.HTTPHeaders, bytes] + # type: (int, httputil.HTTPHeaders, bytes, bool) -> typing.Tuple[int, httputil.HTTPHeaders, bytes] # noqa: E501 return status_code, headers, chunk def transform_chunk(self, chunk, finishing): @@ -2859,7 +2860,7 @@ class GZipContentEncoding(OutputTransform): return ctype.startswith('text/') or ctype in self.CONTENT_TYPES def transform_first_chunk(self, status_code, headers, chunk, finishing): - # type: (int, httputil.HTTPHeaders, bytes, bool) -> typing.Tuple[int, httputil.HTTPHeaders, bytes] + # type: (int, httputil.HTTPHeaders, bytes, bool) -> typing.Tuple[int, httputil.HTTPHeaders, bytes] # noqa: E501 # TODO: can/should this type be inherited from the superclass? if 'Vary' in headers: headers['Vary'] += ', Accept-Encoding' diff --git a/tornado/websocket.py b/tornado/websocket.py index d24a05f16..4b1b220e7 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -539,7 +539,8 @@ class _PerMessageDeflateCompressor(object): self._compressor = None def _create_compressor(self): - return zlib.compressobj(self._compression_level, zlib.DEFLATED, -self._max_wbits, self._mem_level) + return zlib.compressobj(self._compression_level, + zlib.DEFLATED, -self._max_wbits, self._mem_level) def compress(self, data): compressor = self._compressor or self._create_compressor()