Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Update local hacking checks for new flake8. Change-Id: Idffc923ac339978714001be22e3c9ef285e907f5
This commit is contained in:
parent
99f5b075a7
commit
1f35cce0e7
@ -1,4 +1,4 @@
|
||||
hacking>=0.12.0,!=0.13.0,<0.14
|
||||
hacking>=3.0,<4.0.0 # Apache-2.0
|
||||
|
||||
coverage>=3.6
|
||||
fixtures>=1.3.1
|
||||
|
4
tox.ini
4
tox.ini
@ -34,7 +34,9 @@ commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenote
|
||||
# H405 multi line docstring summary not separated with an empty line
|
||||
## TODO(ruhe) following checks should be fixed
|
||||
# E721 do not compare types, use 'isinstance()'
|
||||
# W503 line break before binary operator
|
||||
# W504 line break after binary operator
|
||||
show-source = True
|
||||
ignore = E721,H404,H405,H803
|
||||
ignore = E721,H404,H405,H803,W503,W504
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
|
@ -49,6 +49,7 @@ def detect_version():
|
||||
except pkg_resources.DistributionNotFound:
|
||||
return 'Undefined (package was not installed with setuptools)'
|
||||
|
||||
|
||||
__version__ = detect_version()
|
||||
|
||||
|
||||
@ -117,6 +118,7 @@ def create_context(data=utils.NO_VALUE, context=None, system=True,
|
||||
|
||||
return context
|
||||
|
||||
|
||||
YaqlFactory = factory.YaqlFactory
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ class ContextBase(object):
|
||||
while p is not None:
|
||||
context_predicate = None
|
||||
if predicate:
|
||||
context_predicate = lambda fd: predicate(fd, p)
|
||||
context_predicate = lambda fd: predicate(fd, p) # noqa: E731
|
||||
layer_overloads, is_exclusive = p.get_functions(
|
||||
name, context_predicate, use_convention)
|
||||
p = None if is_exclusive else p.parent
|
||||
@ -137,7 +137,7 @@ class Context(ContextBase):
|
||||
if use_convention and self._convention is not None:
|
||||
name = self._convention.convert_function_name(name)
|
||||
if predicate is None:
|
||||
predicate = lambda x: True
|
||||
predicate = lambda x: True # noqa: E731
|
||||
return (
|
||||
set(six.moves.filter(predicate, self._functions.get(name, set()))),
|
||||
name in self._exclusive_funcs
|
||||
|
@ -33,9 +33,9 @@ class Parser(object):
|
||||
for up, bp, op_name, op_alias in yaql_operators.operators.values():
|
||||
self._aliases[op_name] = op_alias
|
||||
if up:
|
||||
l = precedence_dict.setdefault(
|
||||
la = precedence_dict.setdefault(
|
||||
(abs(up), 'l' if up > 0 else 'r'), [])
|
||||
l.append('UNARY_' + op_name if bp else op_name)
|
||||
la.append('UNARY_' + op_name if bp else op_name)
|
||||
unary_doc += ('value : ' if not unary_doc else '\n| ')
|
||||
spec_prefix = '{0} value' if up > 0 else 'value {0}'
|
||||
if bp:
|
||||
@ -44,14 +44,14 @@ class Parser(object):
|
||||
else:
|
||||
unary_doc += spec_prefix.format(op_name)
|
||||
if bp:
|
||||
l = precedence_dict.setdefault(
|
||||
la = precedence_dict.setdefault(
|
||||
(abs(bp), 'l' if bp > 0 else 'r'), [])
|
||||
if op_name == 'INDEXER':
|
||||
l.extend(('LIST', 'INDEXER'))
|
||||
la.extend(('LIST', 'INDEXER'))
|
||||
elif op_name == 'MAP':
|
||||
l.append('MAP')
|
||||
la.append('MAP')
|
||||
else:
|
||||
l.append(op_name)
|
||||
la.append(op_name)
|
||||
binary_doc += ((
|
||||
'value : ' if not binary_doc else '\n| ') +
|
||||
'value {0} value'.format(op_name))
|
||||
@ -81,7 +81,7 @@ class Parser(object):
|
||||
value = precedence_dict.get((i, oa))
|
||||
if value:
|
||||
precedence.append(
|
||||
(('left',) if oa is 'l' else ('right',)) +
|
||||
(('left',) if oa == 'l' else ('right',)) +
|
||||
tuple(value)
|
||||
)
|
||||
precedence.insert(0, ('left', ','))
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# flake8: noqa: E731
|
||||
|
||||
import sys
|
||||
|
||||
import six
|
||||
@ -107,7 +109,7 @@ def choose_overload(name, candidates, engine, receiver, context, args, kwargs):
|
||||
if len(candidates2) == 0:
|
||||
raise_not_found()
|
||||
|
||||
arg_evaluator = lambda i, arg: (
|
||||
arg_evaluator = lambda i, arg: ( # noqa: E731
|
||||
arg(utils.NO_VALUE, context, engine)
|
||||
if (i not in lazy_params and isinstance(arg, expressions.Expression)
|
||||
and not isinstance(arg, expressions.Constant))
|
||||
|
@ -28,6 +28,7 @@ def create_marker(msg):
|
||||
return msg
|
||||
return MarkerClass()
|
||||
|
||||
|
||||
KEYWORD_REGEX = re.compile(lexer.Lexer.t_KEYWORD_STRING.__doc__.strip())
|
||||
NO_VALUE = create_marker('<NoValue>')
|
||||
|
||||
@ -51,6 +52,7 @@ def is_mutable(obj):
|
||||
collections.MutableSet,
|
||||
collections.MutableMapping))
|
||||
|
||||
|
||||
SequenceType = collections.Sequence
|
||||
MutableSequenceType = collections.MutableSequence
|
||||
SetType = collections.Set
|
||||
|
@ -140,7 +140,7 @@ class MappingRule(LazyParameterType, SmartType):
|
||||
*args, **kwargs):
|
||||
super(MappingRule, self).convert(
|
||||
value, receiver, context, function_spec, engine, *args, **kwargs)
|
||||
wrap = lambda func: lambda: func(receiver, context, engine)
|
||||
wrap = lambda func: lambda: func(receiver, context, engine) # noqa
|
||||
|
||||
return utils.MappingRule(wrap(value.source), wrap(value.destination))
|
||||
|
||||
|
@ -359,7 +359,7 @@ def all_(collection, predicate=None):
|
||||
true
|
||||
"""
|
||||
if predicate is None:
|
||||
predicate = lambda x: bool(x)
|
||||
predicate = lambda x: bool(x) # noqa: E731
|
||||
|
||||
for t in collection:
|
||||
if not predicate(t):
|
||||
@ -1529,10 +1529,10 @@ def merge_with(engine, to_list, d, another, list_merger=None,
|
||||
{"a": 1, "c": [2, 3], "b": 3, "d": 5}
|
||||
"""
|
||||
if list_merger is None:
|
||||
list_merger = lambda lst1, lst2: to_list(
|
||||
list_merger = lambda lst1, lst2: to_list( # noqa: E731
|
||||
distinct(engine, lst1 + lst2))
|
||||
if item_merger is None:
|
||||
item_merger = lambda x, y: y
|
||||
item_merger = lambda x, y: y # noqa: E731
|
||||
return _merge_dicts(d, another, list_merger, item_merger, max_levels)
|
||||
|
||||
|
||||
|
@ -48,7 +48,8 @@ class TestCollections(yaql.tests.TestCase):
|
||||
self.assertTrue(self.eval('isList($.keys().toList())', data=data))
|
||||
|
||||
def test_list_concatenates_and_flatten_generators(self):
|
||||
generator_func = lambda: (i for _ in range(2) for i in range(3))
|
||||
generator_func = lambda: (i for _ in range(2) # noqa: E731
|
||||
for i in range(3))
|
||||
|
||||
self.context['$seq1'] = generator_func()
|
||||
self.context['$seq2'] = generator_func()
|
||||
|
@ -115,7 +115,7 @@ class TestQueries(yaql.tests.TestCase):
|
||||
self.assertEqual(100, self.eval('[].sum(100)'))
|
||||
|
||||
def test_memorize(self):
|
||||
generator_func = lambda: (i for i in range(3))
|
||||
generator_func = lambda: (i for i in range(3)) # noqa: E731
|
||||
self.assertRaises(
|
||||
TypeError,
|
||||
self.eval, '$.len() + $.sum()', data=generator_func())
|
||||
|
@ -70,7 +70,7 @@ class TestSystem(yaql.tests.TestCase):
|
||||
self.eval('[2].select($ + 1).assert(len($) = 1).first()'))
|
||||
|
||||
def test_lambda_passing(self):
|
||||
delegate = lambda x: x ** 2
|
||||
delegate = lambda x: x ** 2 # noqa: E731
|
||||
self.assertEqual(
|
||||
9,
|
||||
self.eval('$(3)', data=delegate))
|
||||
@ -91,7 +91,7 @@ class TestSystem(yaql.tests.TestCase):
|
||||
self.eval('$func(5, z => 2, y => 1)', data=func))
|
||||
|
||||
def test_lambda_expression(self):
|
||||
delegate = lambda x: x ** 2
|
||||
delegate = lambda x: x ** 2 # noqa: E731
|
||||
self.assertEqual(
|
||||
9,
|
||||
self.eval('$.x[0](3)', data={'x': [delegate]}))
|
||||
@ -101,19 +101,19 @@ class TestSystem(yaql.tests.TestCase):
|
||||
self.eval('($.x[0])(3)', data={'x': [delegate]}))
|
||||
|
||||
def test_2nd_order_lambda(self):
|
||||
delegate = lambda y: lambda x: x ** y
|
||||
delegate = lambda y: lambda x: x ** y # noqa: E731
|
||||
self.assertEqual(
|
||||
16,
|
||||
self.eval('$(2)(4)', data=delegate))
|
||||
|
||||
def test_2nd_order_lambda_expression(self):
|
||||
delegate = lambda y: {'key': lambda x: x ** y}
|
||||
delegate = lambda y: {'key': lambda x: x ** y} # noqa: E731
|
||||
self.assertEqual(
|
||||
16,
|
||||
self.eval('$(2)[key](4)', data=delegate))
|
||||
|
||||
def test_2nd_order_lambda_collection_expression(self):
|
||||
delegate = lambda y: lambda x: y ** x
|
||||
delegate = lambda y: lambda x: y ** x # noqa: E731
|
||||
self.assertEqual(
|
||||
[1, 8, 27],
|
||||
self.eval(
|
||||
|
Loading…
Reference in New Issue
Block a user