From 6778e9b2e1d9a4264538012e885d252c892447e5 Mon Sep 17 00:00:00 2001 From: Guillermo Vaya Date: Tue, 16 Jul 2013 16:12:43 +0200 Subject: [PATCH] added @tuturto sugesstions and flake8 errors --- hy/compiler.py | 14 +++++++++----- tests/native_tests/language.hy | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 5b23272..c613b70 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -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, diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index be2393c..00815b1 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -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"