Fixed pep8 checks: E203,E226,E302,E303
* E203 whitespace before ':' * E226 missing whitespace around arithmetic operator * E302 expected 2 blank lines * E303 too many blank lines
This commit is contained in:
parent
c96200fb24
commit
0fb8a303b1
7
tox.ini
7
tox.ini
@ -29,11 +29,6 @@ commands = python setup.py build_sphinx
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
# H404 multi line docstring should start with a summary
|
||||
## TODO(ruhe) following checks should be fixed
|
||||
# E125 continuation line does not distinguish itself from next logical line
|
||||
# E203 whitespace before ':'
|
||||
# E226 missing whitespace around arithmetic operator
|
||||
# E302 expected 2 blank lines
|
||||
# E303 too many blank lines
|
||||
# E501 line too long
|
||||
# E721 do not compare types, use 'isinstance()'
|
||||
# F401 something imported but unused
|
||||
@ -46,6 +41,6 @@ commands = python setup.py build_sphinx
|
||||
# W292 no newline at end of file
|
||||
# W391 blank line at end of file
|
||||
show-source = True
|
||||
ignore = E123,E125,E203,E226,E302,E303,E501,E721,F401,F403,F841,H201,H202,H306,H404,H803,H902,W292,W391
|
||||
ignore = E123,E125,E501,E721,F401,F403,F841,H201,H202,H306,H404,H803,H902,W292,W391
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||
|
@ -32,7 +32,7 @@ def main():
|
||||
decoder = JSONDecoder()
|
||||
data = decoder.decode(json_str)
|
||||
except:
|
||||
print "Unable to load data from "+options.data
|
||||
print "Unable to load data from " + options.data
|
||||
return
|
||||
else:
|
||||
data = None
|
||||
|
@ -19,6 +19,7 @@ from yaql.language.exceptions import YaqlExecutionException
|
||||
def _is_a_number(value):
|
||||
return isinstance(value, (int, long, float, complex))
|
||||
|
||||
|
||||
@parameter('value', custom_validator=_is_a_number)
|
||||
def unary_minus(value):
|
||||
return -1 * value
|
||||
@ -34,6 +35,7 @@ def unary_plus(value):
|
||||
def plus(a, b):
|
||||
return a + b
|
||||
|
||||
|
||||
@parameter('a', custom_validator=_is_a_number)
|
||||
@parameter('b', custom_validator=_is_a_number)
|
||||
def minus(a, b):
|
||||
|
@ -21,11 +21,13 @@ from yaql.language.exceptions import YaqlExecutionException
|
||||
def _and(a, b):
|
||||
return a and b
|
||||
|
||||
|
||||
@parameter('a', arg_type=types.BooleanType)
|
||||
@parameter('b', arg_type=types.BooleanType)
|
||||
def _or(a, b):
|
||||
return a or b
|
||||
|
||||
|
||||
@parameter('data', arg_type=types.BooleanType)
|
||||
def _not(data):
|
||||
return not data
|
||||
|
@ -151,6 +151,7 @@ def take_while(self, predicate):
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
@parameter('self', arg_type=types.GeneratorType)
|
||||
def _list(self):
|
||||
return limit(self)
|
||||
@ -180,4 +181,3 @@ def add_to_context(context):
|
||||
context.register_function(take_while)
|
||||
context.register_function(_list, 'list')
|
||||
context.register_function(for_each)
|
||||
|
||||
|
@ -59,6 +59,7 @@ def resolve_prop(alias, symbol, context):
|
||||
namespace.validate(symbol)
|
||||
return namespace.name + '.' + symbol
|
||||
|
||||
|
||||
@context_aware
|
||||
@parameter('symbol', function_only=True, lazy=True)
|
||||
def resolve_function(self, alias, symbol, context):
|
||||
|
@ -21,6 +21,7 @@ from yaql.language.engine import parameter
|
||||
def string_concatenation(a, b):
|
||||
return a + b
|
||||
|
||||
|
||||
@parameter('self', arg_type=types.StringTypes, is_self=True)
|
||||
def as_list(self):
|
||||
return list(self)
|
||||
@ -29,6 +30,7 @@ def as_list(self):
|
||||
def to_string(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
def _to_string_func(data):
|
||||
return to_string(data)
|
||||
|
||||
|
@ -54,6 +54,7 @@ def dict_attribution(self, att_name):
|
||||
def method_call(self, method):
|
||||
return method(sender=self)
|
||||
|
||||
|
||||
@context_aware
|
||||
@parameter('tuple_preds', lazy=True)
|
||||
def _as(self, context, *tuple_preds):
|
||||
|
@ -39,19 +39,19 @@ unary_prefix = {
|
||||
|
||||
op_to_level = {
|
||||
'abc': 0,
|
||||
'|' : 1,
|
||||
'^' : 2,
|
||||
'&' : 3,
|
||||
'<' : 4,
|
||||
'>' : 4,
|
||||
'=' : 5,
|
||||
'!' : 5,
|
||||
'+' : 6,
|
||||
'-' : 6,
|
||||
'*' : 7,
|
||||
'/' : 7,
|
||||
'%' : 7,
|
||||
'.' : 8
|
||||
'|': 1,
|
||||
'^': 2,
|
||||
'&': 3,
|
||||
'<': 4,
|
||||
'>': 4,
|
||||
'=': 5,
|
||||
'!': 5,
|
||||
'+': 6,
|
||||
'-': 6,
|
||||
'*': 7,
|
||||
'/': 7,
|
||||
'%': 7,
|
||||
'.': 8
|
||||
}
|
||||
|
||||
ops = {
|
||||
@ -86,7 +86,7 @@ tokens = [
|
||||
'FILTER',
|
||||
'NOT',
|
||||
'DOLLAR'
|
||||
] + list(keywords.values())+list(ops.values()) + list(unary_prefix.values())
|
||||
] + list(keywords.values()) + list(ops.values()) + list(unary_prefix.values())
|
||||
|
||||
literals = "()],"
|
||||
|
||||
@ -162,12 +162,11 @@ def t_CHAR_ORB(t):
|
||||
return t
|
||||
|
||||
|
||||
|
||||
def get_orb_op_type(first_char, last_char):
|
||||
if first_char.isalpha() or first_char == '_':
|
||||
level = op_to_level['abc']
|
||||
else:
|
||||
level = op_to_level.get(first_char, max(op_to_level.values())+1)
|
||||
level = op_to_level.get(first_char, max(op_to_level.values()) + 1)
|
||||
asc = 'r' if last_char in right_associative else 'l'
|
||||
return ops.get((level, asc))
|
||||
|
||||
|
@ -140,7 +140,6 @@ def p_binary(p):
|
||||
p[0] = expressions.BinaryOperator(p[2], p[1], p[3])
|
||||
|
||||
|
||||
|
||||
def p_unary_prefix(p):
|
||||
"""
|
||||
value : UNARY_TILDE value
|
||||
|
@ -50,6 +50,7 @@ def override_with_caps(self, context):
|
||||
def _print(self):
|
||||
return "data is: %s" % self
|
||||
|
||||
|
||||
@parameter('self', arg_type=types.StringType)
|
||||
def print_string(self):
|
||||
return "print %s" % self
|
||||
@ -63,7 +64,6 @@ class TestExecutionChain(YaqlTest):
|
||||
self.context.register_function(_print, 'print')
|
||||
self.context.register_function(override_with_caps, 'caps_on')
|
||||
|
||||
|
||||
def test_chain1(self):
|
||||
expression = 'f1(abc).f2().f3()'
|
||||
self.assertEquals('f3(f2(f1(abc)))', self.eval(expression))
|
||||
@ -103,7 +103,5 @@ class TestExecutionChain(YaqlTest):
|
||||
self.assertRaises(YaqlExecutionException, self.eval, wrong_expression)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -54,6 +54,5 @@ class TestTuples(YaqlTest):
|
||||
self.assertEquals((5, 'a'), self.eval(expression2))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user