Fixed E731 flake8 errors
do not assign a lambda expression, use a def
This commit is contained in:
parent
15610289ac
commit
b49e8baab3
|
@ -136,7 +136,8 @@ class Source(object):
|
||||||
try:
|
try:
|
||||||
import parser
|
import parser
|
||||||
except ImportError:
|
except ImportError:
|
||||||
syntax_checker = lambda x: compile(x, 'asd', 'exec')
|
def syntax_checker(x):
|
||||||
|
return compile(x, 'asd', 'exec')
|
||||||
else:
|
else:
|
||||||
syntax_checker = parser.suite
|
syntax_checker = parser.suite
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ ASCII_IS_DEFAULT_ENCODING = sys.version_info[0] < 3
|
||||||
if sys.version_info >= (3, 5):
|
if sys.version_info >= (3, 5):
|
||||||
ast_Call = ast.Call
|
ast_Call = ast.Call
|
||||||
else:
|
else:
|
||||||
ast_Call = lambda a, b, c: ast.Call(a, b, c, None, None)
|
def ast_Call(a, b, c):
|
||||||
|
return ast.Call(a, b, c, None, None)
|
||||||
|
|
||||||
|
|
||||||
class AssertionRewritingHook(object):
|
class AssertionRewritingHook(object):
|
||||||
|
|
|
@ -111,11 +111,17 @@ def assertrepr_compare(config, op, left, right):
|
||||||
|
|
||||||
summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))
|
summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))
|
||||||
|
|
||||||
issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) and
|
def issequence(x):
|
||||||
not isinstance(x, basestring))
|
return (isinstance(x, (list, tuple, Sequence)) and not isinstance(x, basestring))
|
||||||
istext = lambda x: isinstance(x, basestring)
|
|
||||||
isdict = lambda x: isinstance(x, dict)
|
def istext(x):
|
||||||
isset = lambda x: isinstance(x, (set, frozenset))
|
return isinstance(x, basestring)
|
||||||
|
|
||||||
|
def isdict(x):
|
||||||
|
return isinstance(x, dict)
|
||||||
|
|
||||||
|
def isset(x):
|
||||||
|
return isinstance(x, (set, frozenset))
|
||||||
|
|
||||||
def isiterable(obj):
|
def isiterable(obj):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1415,7 +1415,10 @@ class approx(object):
|
||||||
# or a sequence of numbers, return a list of ApproxNotIterable objects
|
# or a sequence of numbers, return a list of ApproxNotIterable objects
|
||||||
# that can be compared against.
|
# that can be compared against.
|
||||||
from collections import Iterable
|
from collections import Iterable
|
||||||
approx_non_iter = lambda x: ApproxNonIterable(x, self.rel, self.abs)
|
|
||||||
|
def approx_non_iter(x):
|
||||||
|
return ApproxNonIterable(x, self.rel, self.abs)
|
||||||
|
|
||||||
if isinstance(self._expected, Iterable):
|
if isinstance(self._expected, Iterable):
|
||||||
return [approx_non_iter(x) for x in self._expected]
|
return [approx_non_iter(x) for x in self._expected]
|
||||||
else:
|
else:
|
||||||
|
@ -1489,7 +1492,8 @@ class ApproxNonIterable(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tolerance(self):
|
def tolerance(self):
|
||||||
set_default = lambda x, default: x if x is not None else default
|
def set_default(x, default):
|
||||||
|
return x if x is not None else default
|
||||||
|
|
||||||
# Figure out what the absolute tolerance should be. ``self.abs`` is
|
# Figure out what the absolute tolerance should be. ``self.abs`` is
|
||||||
# either None or a value specified by the user.
|
# either None or a value specified by the user.
|
||||||
|
|
|
@ -22,7 +22,10 @@ class SessionTests(object):
|
||||||
assert len(skipped) == 0
|
assert len(skipped) == 0
|
||||||
assert len(passed) == 1
|
assert len(passed) == 1
|
||||||
assert len(failed) == 3
|
assert len(failed) == 3
|
||||||
end = lambda x: x.nodeid.split("::")[-1]
|
|
||||||
|
def end(x):
|
||||||
|
return x.nodeid.split("::")[-1]
|
||||||
|
|
||||||
assert end(failed[0]) == "test_one_one"
|
assert end(failed[0]) == "test_one_one"
|
||||||
assert end(failed[1]) == "test_other"
|
assert end(failed[1]) == "test_other"
|
||||||
itemstarted = reprec.getcalls("pytest_itemcollected")
|
itemstarted = reprec.getcalls("pytest_itemcollected")
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -196,6 +196,5 @@ filterwarnings =
|
||||||
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E731
|
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
exclude = _pytest/vendored_packages/pluggy.py
|
exclude = _pytest/vendored_packages/pluggy.py
|
||||||
|
|
Loading…
Reference in New Issue