Skip to content

Commit

Permalink
Merge pull request #196 from onefinestay/new_pyflakes
Browse files Browse the repository at this point in the history
fix for newer pyflakes
  • Loading branch information
davidszotten committed Feb 9, 2015
2 parents 1b52f4b + 74d6a76 commit 824c316
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 27 deletions.
5 changes: 4 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
-r contrib_requirements.txt

coverage==4.0a1
flake8==2.1
flake8==2.1.0
mccabe==0.3
pep8==1.6.1
pyflakes==0.8.1
pylint==1.0.0
pytest==2.4.2
Sphinx==1.2
8 changes: 3 additions & 5 deletions nameko/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"""

import eventlet

eventlet.monkey_patch()

eventlet.monkey_patch() # noqa (code before rest of imports)

import errno
import logging
Expand Down Expand Up @@ -60,7 +58,7 @@ def import_service(module_name):
raise CommandError(
"Failed to find service class {!r} in module {!r}".format(
obj, module_name)
)
)

if not isinstance(service_cls, type):
raise CommandError("Service must be a class.")
Expand Down Expand Up @@ -147,7 +145,7 @@ def init_parser(parser):
'--broker', default='amqp://guest:guest@localhost:5672/nameko',
help='RabbitMQ broker url')
parser.add_argument(
'--backdoor-port', type=int,
'--backdoor-port', type=int,
help='Specity a port number to host a backdoor, which can be connected'
' to for an interactive interpreter within the running service'
' process using `nameko backdoor`.'
Expand Down
9 changes: 7 additions & 2 deletions nameko/legacy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@

import iso8601

UIDGEN = lambda: uuid.uuid4().hex
UTCNOW = lambda: datetime.datetime.now(iso8601.iso8601.UTC)

def UIDGEN():
return uuid.uuid4().hex


def UTCNOW():
return datetime.datetime.now(iso8601.iso8601.UTC)
2 changes: 1 addition & 1 deletion nameko/legacy/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _send_topic(connection, exchange, topic, data):
ch.channel,
exchange=exchange,
routing_key=topic,
)
)
ch.ensure(producer.publish)(data, declare=[exchange], mandatory=True,
retry_policy=DEFAULT_RETRY_POLICY,
retry=True)
Expand Down
4 changes: 3 additions & 1 deletion nameko/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def get_dependency(container, dependency_cls, **match_attrs):
if not match_attrs:
return dep

has_attribute = lambda name, value: getattr(dep, name) == value
def has_attribute(name, value):
return getattr(dep, name) == value

if all([has_attribute(name, value)
for name, value in match_attrs.items()]):
return dep
Expand Down
2 changes: 1 addition & 1 deletion test/cli/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def fake_argv():
'--broker',
'my_broker',
'test.sample:Service',
],
],
):
yield

Expand Down
2 changes: 1 addition & 1 deletion test/cli/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_run(rabbit_config):
'--backdoor-port',
0,
'test.sample:Service',
])
])
gt = eventlet.spawn(main, args)
eventlet.sleep(1)

Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import eventlet
eventlet.monkey_patch()
eventlet.monkey_patch() # noqa (code before rest of imports)

import itertools
import logging
Expand Down
5 changes: 4 additions & 1 deletion test/legacy/test_channelhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def test_ensure():
handler, handler.close, on_revive=handler.revive)

obj = {}
fn = lambda: None

def fn():
return None

handler.ensure((obj, fn))
conn.ensure.assert_called_with(obj, fn, on_revive=None)

Expand Down
20 changes: 8 additions & 12 deletions test/legacy/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def test_anon_context_constructor():
def test_call(nova, constructor):
connection = ANY
context = Mock()
context_factory = lambda: context
rpcproxy = constructor(context_factory=context_factory)
rpcproxy = constructor(context_factory=lambda: context)

with pytest.raises(ValueError):
# no topic, no method
Expand All @@ -41,8 +40,7 @@ def test_call(nova, constructor):
def test_call_dynamic_route(nova, constructor):
connection = ANY
context = Mock()
context_factory = lambda: context
rpcproxy = constructor(context_factory=context_factory)
rpcproxy = constructor(context_factory=lambda: context)

with pytest.raises(ValueError):
# no topic, no method
Expand Down Expand Up @@ -70,8 +68,7 @@ def test_call_dynamic_route(nova, constructor):
def test_call_default(nova, constructor):
connection = ANY
context = Mock()
context_factory = lambda: context
rpcproxy = constructor(context_factory=context_factory)
rpcproxy = constructor(context_factory=lambda: context)

rpcproxy.service.controller(key='value')

Expand Down Expand Up @@ -108,9 +105,8 @@ def test_route_abuse(nova, constructor):
def test_control_exchange_config(rpc, constructor):
connection = ANY
context = Mock()
context_factory = lambda: context
rpcproxy = constructor(
control_exchange='rpc', context_factory=context_factory)
control_exchange='rpc', context_factory=lambda: context)

rpcproxy.service.controller(key='value')

Expand Down Expand Up @@ -214,9 +210,7 @@ def test_add_call_matching():
def test_service_whitelist(nova):
connection = ANY
context = Mock()
context_factory = lambda: context
rpcproxy = MockRPCProxy(
context_factory=context_factory)
rpcproxy = MockRPCProxy(context_factory=lambda: context)
rpcproxy.fallback_to_call = False

with pytest.raises(RuntimeError):
Expand Down Expand Up @@ -258,7 +252,9 @@ def test_fallback_to_call():
def test_timeout(nova, constructor):
connection = ANY
context = Mock()
context_factory = lambda: context

def context_factory():
return context

# test null timeout
rpcproxy = constructor(context_factory=context_factory)
Expand Down
4 changes: 3 additions & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def slow_call():
sleep(5)
slow_call_returned.send()

identity_fn = lambda x: x()
def identity_fn(fn):
return fn()

calls = [slow_call, failing_call]

pool = GreenPool(2)
Expand Down

0 comments on commit 824c316

Please sign in to comment.