diff options
author | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-05-31 19:55:43 -0300 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2016-06-06 20:22:26 -0400 |
commit | 3e4870f8bd6186f3d0821f392a0dafc5d5247ad4 (patch) | |
tree | 51f3ea8031c490cfc39c3ece7b2f013dbe3cdb88 /common/src | |
parent | 3f9e88b0c4d03aba4e406143813777f14635e20d (diff) |
[style] remove misused lambdas
Pep8 was warning about assignment of lambdas. These lambdas should
be partials
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/leap/soledad/common/backend.py | 5 | ||||
-rw-r--r-- | common/src/leap/soledad/common/couch/__init__.py | 3 | ||||
-rw-r--r-- | common/src/leap/soledad/common/tests/test_command.py | 5 |
3 files changed, 8 insertions, 5 deletions
diff --git a/common/src/leap/soledad/common/backend.py b/common/src/leap/soledad/common/backend.py index 53426fb5..0a36c068 100644 --- a/common/src/leap/soledad/common/backend.py +++ b/common/src/leap/soledad/common/backend.py @@ -18,7 +18,7 @@ """A U1DB generic backend.""" - +import functools from u1db import vectorclock from u1db.errors import ( RevisionConflict, @@ -438,9 +438,8 @@ class SoledadBackend(CommonBackend): generation. :type other_transaction_id: str """ - function = self._set_replica_gen_and_trans_id args = [other_replica_uid, other_generation, other_transaction_id] - callback = lambda: function(*args) + callback = functools.partial(self._set_replica_gen_and_trans_id, *args) if self.batching: self.after_batch_callbacks['set_source_info'] = callback else: diff --git a/common/src/leap/soledad/common/couch/__init__.py b/common/src/leap/soledad/common/couch/__init__.py index 18ed8a19..5bda8071 100644 --- a/common/src/leap/soledad/common/couch/__init__.py +++ b/common/src/leap/soledad/common/couch/__init__.py @@ -24,6 +24,7 @@ import re import uuid import binascii import time +import functools from StringIO import StringIO @@ -340,7 +341,7 @@ class CouchDatabase(object): # This will not be needed when/if we switch from python-couchdb to # paisley. time.strptime('Mar 8 1917', '%b %d %Y') - get_one = lambda doc_id: self.get_doc(doc_id, check_for_conflicts) + get_one = functools.partial(self.get_doc, check_for_conflicts=check_for_conflicts) docs = [THREAD_POOL.apply_async(get_one, [doc_id]) for doc_id in doc_ids] for doc in docs: diff --git a/common/src/leap/soledad/common/tests/test_command.py b/common/src/leap/soledad/common/tests/test_command.py index c386bdd2..2136bb8f 100644 --- a/common/src/leap/soledad/common/tests/test_command.py +++ b/common/src/leap/soledad/common/tests/test_command.py @@ -21,10 +21,13 @@ from twisted.trial import unittest from leap.soledad.common.command import exec_validated_cmd +def validator(arg): + return True if arg is 'valid' else False + + class ExecuteValidatedCommandTest(unittest.TestCase): def test_argument_validation(self): - validator = lambda arg: True if arg is 'valid' else False status, out = exec_validated_cmd("command", "invalid arg", validator) self.assertEquals(status, 1) self.assertEquals(out, "invalid argument") |