From d823c628ff500e8c0d399e9a505efbf196879426 Mon Sep 17 00:00:00 2001 From: Ask Solem Date: Wed, 15 Jun 2016 17:48:41 -0700 Subject: [PATCH] flakes --- examples/rpc-tut6/rpc_server.py | 2 +- examples/simple_task_queue/tasks.py | 1 + kombu/__init__.py | 18 ++++++++++-------- kombu/messaging.py | 2 +- kombu/tests/transport/test_qpid.py | 2 +- kombu/transport/redis.py | 16 +++++++++++----- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/examples/rpc-tut6/rpc_server.py b/examples/rpc-tut6/rpc_server.py index c9c496b7..bb64726b 100644 --- a/examples/rpc-tut6/rpc_server.py +++ b/examples/rpc-tut6/rpc_server.py @@ -13,7 +13,7 @@ def fib(n): elif n == 1: return 1 else: - return fib(n-1) + fib(n-2) + return fib(n - 1) + fib(n - 2) class Worker(ConsumerProducerMixin): diff --git a/examples/simple_task_queue/tasks.py b/examples/simple_task_queue/tasks.py index 1d520fad..99258ce3 100644 --- a/examples/simple_task_queue/tasks.py +++ b/examples/simple_task_queue/tasks.py @@ -1,4 +1,5 @@ from __future__ import absolute_import, unicode_literals + def hello_task(who='world'): print('Hello {0}'.format(who)) diff --git a/kombu/__init__.py b/kombu/__init__.py index f1663b47..bd1c0306 100644 --- a/kombu/__init__.py +++ b/kombu/__init__.py @@ -44,14 +44,16 @@ if STATICA_HACK: # pragma: no cover from types import ModuleType # noqa all_by_module = { - 'kombu.connection': ['Connection', 'BrokerConnection'], - 'kombu.entity': ['Exchange', 'Queue', 'binding'], - 'kombu.messaging': ['Consumer', 'Producer'], - 'kombu.pools': ['connections', 'producers'], - 'kombu.utils.url': ['parse_url'], - 'kombu.common': ['eventloop', 'uuid'], - 'kombu.serialization': ['enable_insecure_serializers', - 'disable_insecure_serializers'], + 'kombu.connection': ['Connection', 'BrokerConnection'], + 'kombu.entity': ['Exchange', 'Queue', 'binding'], + 'kombu.messaging': ['Consumer', 'Producer'], + 'kombu.pools': ['connections', 'producers'], + 'kombu.utils.url': ['parse_url'], + 'kombu.common': ['eventloop', 'uuid'], + 'kombu.serialization': [ + 'enable_insecure_serializers', + 'disable_insecure_serializers', + ], } object_origins = {} diff --git a/kombu/messaging.py b/kombu/messaging.py index 460ced97..629764f7 100644 --- a/kombu/messaging.py +++ b/kombu/messaging.py @@ -167,7 +167,7 @@ class Producer(object): ) if expiration is not None: - properties['expiration'] = str(int(expiration*1000)) + properties['expiration'] = str(int(expiration * 1000)) body, content_type, content_encoding = self._prepare( body, serializer, content_type, content_encoding, diff --git a/kombu/tests/transport/test_qpid.py b/kombu/tests/transport/test_qpid.py index a33c9658..d25ed0b1 100644 --- a/kombu/tests/transport/test_qpid.py +++ b/kombu/tests/transport/test_qpid.py @@ -1453,7 +1453,7 @@ class test_Transport__init(QPidCase): def test_sets_non_blocking_behavior_on_r_fd(self): Transport(Mock()) self.fcntl.fcntl.assert_called_once_with( - self.r, self.fcntl.F_SETFL, self.os.O_NONBLOCK) + self.r, self.fcntl.F_SETFL, self.os.O_NONBLOCK) class test_Transport__drain_events(QPidCase): diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py index fe29689c..45a4dfe0 100644 --- a/kombu/transport/redis.py +++ b/kombu/transport/redis.py @@ -649,12 +649,18 @@ class Channel(virtual.Channel): def _handle_message(self, client, r): if bytes_to_str(r[0]) == 'unsubscribe' and r[2] == 0: client.subscribed = False - elif bytes_to_str(r[0]) == 'pmessage': - return {'type': r[0], 'pattern': r[1], - 'channel': r[2], 'data': r[3]} + return + + if bytes_to_str(r[0]) == 'pmessage': + type, pattern, channel, data = r[0], r[1], r[2], r[3] else: - return {'type': r[0], 'pattern': None, - 'channel': r[1], 'data': r[2]} + type, pattern, channel, data = r[0], None, r[1], r[2] + return { + 'type': type, + 'pattern': pattern, + 'channel': channel, + 'data': data, + } def _receive(self): c = self.subclient