mirror of https://github.com/celery/kombu.git
Prefer dict literal syntax over dict() (#787)
* Prefer dict literal syntax over dict() * An overlooked dict-constructor in transport/SQS.py
This commit is contained in:
parent
c292e9d400
commit
65d203c71e
1
AUTHORS
1
AUTHORS
|
@ -83,6 +83,7 @@ Latitia M. Haskins <lhaskins@jetsonsys.com>
|
|||
Len Buckens <buckens.len@gmail.com>
|
||||
Lorenzo Mancini <lmancini@develer.com>
|
||||
Luyun Xie <2304310@qq.com>
|
||||
Mads Jensen <https://github.com/atombrella>
|
||||
Mahendra M <Mahendra_M@infosys.com>
|
||||
Marcin Lulek (ergo) <info@webreactor.eu>
|
||||
Mark Lavin <mlavin@caktusgroup.com>
|
||||
|
|
|
@ -144,8 +144,8 @@ class SimpleBuffer(SimpleQueue):
|
|||
"""Simple API for ephemeral queues."""
|
||||
|
||||
no_ack = True
|
||||
queue_opts = dict(durable=False,
|
||||
auto_delete=True)
|
||||
exchange_opts = dict(durable=False,
|
||||
delivery_mode='transient',
|
||||
auto_delete=True)
|
||||
queue_opts = {'durable': False,
|
||||
'auto_delete': True}
|
||||
exchange_opts = {'durable': False,
|
||||
'delivery_mode': 'transient',
|
||||
'auto_delete': True}
|
||||
|
|
|
@ -420,9 +420,9 @@ class Channel(virtual.Channel):
|
|||
aws_secret_access_key=self.conninfo.password,
|
||||
)
|
||||
is_secure = self.is_secure if self.is_secure is not None else True
|
||||
client_kwargs = dict(
|
||||
use_ssl=is_secure
|
||||
)
|
||||
client_kwargs = {
|
||||
'use_ssl': is_secure
|
||||
}
|
||||
if self.endpoint_url is not None:
|
||||
client_kwargs['endpoint_url'] = self.endpoint_url
|
||||
self._sqs = session.client('sqs', **client_kwargs)
|
||||
|
|
|
@ -381,15 +381,15 @@ class Channel(virtual.Channel):
|
|||
|
||||
def _create_broadcast_cursor(self, exchange, routing_key, pattern, queue):
|
||||
if pymongo.version_tuple >= (3, ):
|
||||
query = dict(
|
||||
filter={'queue': exchange},
|
||||
cursor_type=CursorType.TAILABLE
|
||||
)
|
||||
query = {
|
||||
'filter': {'queue': exchange},
|
||||
'cursor_type': CursorType.TAILABLE,
|
||||
}
|
||||
else:
|
||||
query = dict(
|
||||
query={'queue': exchange},
|
||||
tailable=True
|
||||
)
|
||||
query = {
|
||||
'query': {'queue': exchange},
|
||||
'tailable': True,
|
||||
}
|
||||
|
||||
cursor = self.broadcast.find(**query)
|
||||
ret = self._broadcast_cursors[queue] = BroadcastCursor(cursor)
|
||||
|
|
|
@ -857,7 +857,7 @@ class Management(base.Management):
|
|||
self.channel = transport.client.channel()
|
||||
|
||||
def get_bindings(self):
|
||||
return [dict(destination=q, source=e, routing_key=r)
|
||||
return [{'destination': q, 'source': e, 'routing_key': r}
|
||||
for q, e, r in self.channel.list_bindings()]
|
||||
|
||||
def close(self):
|
||||
|
|
12
t/mocks.py
12
t/mocks.py
|
@ -67,12 +67,12 @@ class Channel(base.StdChannel):
|
|||
def prepare_message(self, body, priority=0, content_type=None,
|
||||
content_encoding=None, headers=None, properties={}):
|
||||
self._called('prepare_message')
|
||||
return dict(body=body,
|
||||
headers=headers,
|
||||
properties=properties,
|
||||
priority=priority,
|
||||
content_type=content_type,
|
||||
content_encoding=content_encoding)
|
||||
return {'body': body,
|
||||
'headers': headers,
|
||||
'properties': properties,
|
||||
'priority': priority,
|
||||
'content_type': content_type,
|
||||
'content_encoding': content_encoding}
|
||||
|
||||
def basic_publish(self, message, exchange='', routing_key='',
|
||||
mandatory=False, immediate=False, **kwargs):
|
||||
|
|
|
@ -65,38 +65,38 @@ class test_connection_utils:
|
|||
|
||||
@pytest.mark.parametrize('url,expected', [
|
||||
('amqp://user:pass@host:10000/vhost',
|
||||
dict(userid='user', password='pass', hostname='host',
|
||||
port=10000, virtual_host='vhost')),
|
||||
{'userid': 'user', 'password': 'pass', 'hostname': 'host',
|
||||
'port': 10000, 'virtual_host': 'vhost'}),
|
||||
('amqp://user%61:%61pass@ho%61st:10000/v%2fhost',
|
||||
dict(userid='usera', password='apass', hostname='hoast',
|
||||
port=10000, virtual_host='v/host')),
|
||||
{'userid': 'usera', 'password': 'apass', 'hostname': 'hoast',
|
||||
'port': 10000, 'virtual_host': 'v/host'}),
|
||||
('amqp://',
|
||||
dict(userid='guest', password='guest', hostname='localhost',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'localhost',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
('amqp://:@/',
|
||||
dict(userid='guest', password='guest', hostname='localhost',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'localhost',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
('amqp://user@/',
|
||||
dict(userid='user', password='guest', hostname='localhost',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'user', 'password': 'guest', 'hostname': 'localhost',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
('amqp://user:pass@/',
|
||||
dict(userid='user', password='pass', hostname='localhost',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'user', 'password': 'pass', 'hostname': 'localhost',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
('amqp://host',
|
||||
dict(userid='guest', password='guest', hostname='host',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'host',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
('amqp://:10000',
|
||||
dict(userid='guest', password='guest', hostname='localhost',
|
||||
port=10000, virtual_host='/')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'localhost',
|
||||
'port': 10000, 'virtual_host': '/'}),
|
||||
('amqp:///vhost',
|
||||
dict(userid='guest', password='guest', hostname='localhost',
|
||||
port=5672, virtual_host='vhost')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'localhost',
|
||||
'port': 5672, 'virtual_host': 'vhost'}),
|
||||
('amqp://host/',
|
||||
dict(userid='guest', password='guest', hostname='host',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'host',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
('amqp://host/%2f',
|
||||
dict(userid='guest', password='guest', hostname='host',
|
||||
port=5672, virtual_host='/')),
|
||||
{'userid': 'guest', 'password': 'guest', 'hostname': 'host',
|
||||
'port': 5672, 'virtual_host': '/'}),
|
||||
])
|
||||
def test_rabbitmq_example_urls(self, url, expected):
|
||||
# see Appendix A of http://www.rabbitmq.com/uri-spec.html
|
||||
|
|
|
@ -553,7 +553,7 @@ class test_Transport:
|
|||
self.transport = client().transport
|
||||
|
||||
def test_custom_polling_interval(self):
|
||||
x = client(transport_options=dict(polling_interval=32.3))
|
||||
x = client(transport_options={'polling_interval': 32.3})
|
||||
assert x.transport.polling_interval == 32.3
|
||||
|
||||
def test_close_connection(self):
|
||||
|
|
|
@ -145,12 +145,12 @@ class test_ExchangeType(ExchangeCase):
|
|||
'rFoo', None, 'qFoo',
|
||||
)
|
||||
|
||||
e1 = dict(
|
||||
type='direct',
|
||||
durable=True,
|
||||
auto_delete=True,
|
||||
arguments={},
|
||||
)
|
||||
e1 = {
|
||||
'type': 'direct',
|
||||
'durable': True,
|
||||
'auto_delete': True,
|
||||
'arguments': {},
|
||||
}
|
||||
e2 = dict(e1, arguments={'expires': 3000})
|
||||
|
||||
@pytest.mark.parametrize('ex,eq,name,type,durable,auto_delete,arguments', [
|
||||
|
|
Loading…
Reference in New Issue