diff --git a/ipapython/install/core.py b/ipapython/install/core.py index 7f638914c..efdc1bbfa 100644 --- a/ipapython/install/core.py +++ b/ipapython/install/core.py @@ -415,7 +415,11 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)): def __runner(self, pending_state, running_state, exc_handler): self.__transition(pending_state, running_state) - step = lambda: next(self.__gen) + def step_next(): + return next(self.__gen) + + step = step_next + while True: try: step() @@ -440,9 +444,13 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)): yield except BaseException: exc_info = sys.exc_info() - step = lambda: self.__gen.throw(*exc_info) + + def step_throw(): + return self.__gen.throw(*exc_info) + + step = step_throw else: - step = lambda: next(self.__gen) + step = step_next def _handle_exception(self, exc_info): assert not hasattr(super(Configurable, self), '_handle_exception') diff --git a/ipaserver/plugins/idrange.py b/ipaserver/plugins/idrange.py index d5b184fcd..3eca90a5b 100644 --- a/ipaserver/plugins/idrange.py +++ b/ipaserver/plugins/idrange.py @@ -426,7 +426,8 @@ class idrange_add(LDAPCreate): def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): assert isinstance(dn, DN) - is_set = lambda x: (x in entry_attrs) and (entry_attrs[x] is not None) + def is_set(x): + return entry_attrs.get(x) is not None # This needs to stay in options since there is no # ipanttrusteddomainname attribute in LDAP @@ -685,11 +686,13 @@ class idrange_mod(LDAPUpdate): '`ipa help idrange` for more information') ) - is_set = lambda x: (x in entry_attrs) and (entry_attrs[x] is not None) - in_updated_attrs = lambda x:\ - (x in entry_attrs and entry_attrs[x] is not None) or\ - (x not in entry_attrs and x in old_attrs - and old_attrs[x] is not None) + def is_set(x): + return entry_attrs.get(x) is not None + + def in_updated_attrs(x): + return is_set(x) or ( + x not in entry_attrs and old_attrs.get(x) is not None + ) # This needs to stay in options since there is no # ipanttrusteddomainname attribute in LDAP diff --git a/ipatests/test_ipalib/test_frontend.py b/ipatests/test_ipalib/test_frontend.py index ad2f67dbf..e9da505b4 100644 --- a/ipatests/test_ipalib/test_frontend.py +++ b/ipatests/test_ipalib/test_frontend.py @@ -211,7 +211,9 @@ class test_Command(ClassChecker): lambda arg: arg, 'default_from' ) - normalizer = lambda value: value.lower() + + def normalizer(value): + return value.lower() class example(self.cls): takes_options = ( diff --git a/ipatests/test_ipalib/test_parameters.py b/ipatests/test_ipalib/test_parameters.py index fd1819024..9feb613b5 100644 --- a/ipatests/test_ipalib/test_parameters.py +++ b/ipatests/test_ipalib/test_parameters.py @@ -73,8 +73,7 @@ class test_DefaultFrom(ClassChecker): o = self.cls(callback, *keys) assert read_only(o, 'callback') is callback assert read_only(o, 'keys') == keys - lam = lambda first, last: first[0] + last - o = self.cls(lam) + o = self.cls(lambda first, last: first[0] + last) assert read_only(o, 'keys') == ('first', 'last') # Test that TypeError is raised when callback isn't callable: @@ -108,7 +107,8 @@ class test_DefaultFrom(ClassChecker): o = self.cls(stuff, 'aye', 'bee', 'see') assert repr(o) == "DefaultFrom('aye', 'bee', 'see')" - cb = lambda first, last: first[0] + last + def cb(first, last): + return first[0] + last o = self.cls(cb) assert repr(o) == "DefaultFrom('first', 'last')" @@ -293,7 +293,9 @@ class test_Param(ClassChecker): ) # Test that default_from gets set: - call = lambda first, last: first[0] + last + def call(first, last): + return first[0] + last + o = self.cls('my_param', default_from=call) assert type(o.default_from) is parameters.DefaultFrom assert o.default_from.callback is call diff --git a/ipatests/test_util.py b/ipatests/test_util.py index 047e7ec43..3210da60d 100644 --- a/ipatests/test_util.py +++ b/ipatests/test_util.py @@ -81,7 +81,8 @@ class test_Fuzzy: assert inst.test is None assert isinstance(inst.re, pattern_type) - t = lambda other: other > 500 + def t(other): + return other > 500 inst = self.klass(test=t) assert inst.regex is None @@ -97,7 +98,9 @@ class test_Fuzzy: def test_repr(self): s = 'Fuzzy(%r, %r, %r)' - t = lambda other: 0.0 <= other <= 1.0 + + def t(other): + return 0.0 <= other <= 1.0 inst = self.klass() assert repr(inst) == s % (None, None, None) @@ -129,7 +132,9 @@ class test_Fuzzy: assert (self.klass(type=int) == 18) is True assert (self.klass(type=(int, str)) == '18') is True - t = lambda other: other.endswith('bar') + def t(other): + return other.endswith('bar') + assert (self.klass(test=t) == 'foobar') is True assert (self.klass(test=t, type=unicode) == b'foobar') is False assert (self.klass(test=t) == 'barfoo') is False diff --git a/pylintrc b/pylintrc index 3a09c610e..fe5e190e0 100644 --- a/pylintrc +++ b/pylintrc @@ -74,7 +74,6 @@ disable= super-init-not-called, undefined-loop-variable, unnecessary-lambda, - unnecessary-lambda-assignment, unused-argument, useless-else-on-loop, bad-continuation,