added @tuturto sugesstions and flake8 errors

This commit is contained in:
Guillermo Vaya 2013-07-16 16:12:43 +02:00
parent dda291cfb5
commit 6778e9b2e1
2 changed files with 10 additions and 6 deletions

View File

@ -334,11 +334,14 @@ def checkargs(exact=None, min=None, max=None, even=None):
_raise_wrong_args_number(
expression,
"`%%s' needs at most %d arguments, got %%d" % (max))
is_even = not((len(expression) - 1) % 2)
if even is not None and is_even!=even:
if even is not None and is_even != even:
even_str = "even" if even else "odd"
_raise_wrong_args_number(expression, "`%%s' needs an %s number of arguments, got %%d" % (even_str))
_raise_wrong_args_number(
expression,
"`%%s' needs an %s number of arguments, got %%d"
% (even_str))
return fn(self, expression)
@ -1141,12 +1144,13 @@ class HyASTCompiler(object):
# (assoc foo bar baz) => foo[bar] = baz
target = self.compile(expr.pop(0))
ret = target
while expr != []:
while expr:
key = self.compile(expr.pop(0))
try:
val = self.compile(expr.pop(0))
except IndexError:
raise HyCompileError("Key {key} has no value to associate".format(key))
raise HyCompileError(
"Key {key} has no value to associate".format(key))
ret += key + val + ast.Assign(
lineno=expr.start_line,

View File

@ -352,7 +352,7 @@
"NATIVE: test assoc multiple values"
(setv vals {"one" "two"})
(assoc vals "two" "three" "four" "five")
(assert (and (= (get vals "two") "three") (= (get vals "four") "five"))))
(assert (and (= (get vals "two") "three") (= (get vals "four") "five") (= (get vals "one") "two"))))
(defn test-pass []
"NATIVE: Test pass worksish"