From 4cc84872db1d9684c148cbdbf7949ce61359a76b Mon Sep 17 00:00:00 2001 From: Daniel Flook Date: Mon, 14 Oct 2024 15:20:04 +0100 Subject: [PATCH] Remove trailing whitespace --- test/test_assignment_expressions.py | 4 +- test/test_bind_names.py | 8 +-- test/test_combine_imports.py | 2 +- test/test_hoist_literals.py | 16 +++--- test/test_match.py | 6 +-- test/test_match_rename.py | 56 +++++++++---------- test/test_nonlocal.py | 2 +- test/test_remove_annotations.py | 2 +- test/test_remove_assert.py | 8 +-- test/test_remove_debug.py | 14 ++--- test/test_remove_pass.py | 8 +-- test/test_rename_locals.py | 84 ++++++++++++++--------------- test/test_type_param_defaults.py | 1 + 13 files changed, 106 insertions(+), 105 deletions(-) diff --git a/test/test_assignment_expressions.py b/test/test_assignment_expressions.py index c88e0b92..6fa44450 100644 --- a/test/test_assignment_expressions.py +++ b/test/test_assignment_expressions.py @@ -15,9 +15,9 @@ def test_pep(): if a := True: print(a) if self._is_special and (ans := self._check_nans(context=context)): - return ans + return ans results = [(x, y, x/y) for x in input_data if (y := f(x)) > 0] -stuff = [[y := f(x), x/y] for x in range(5)] +stuff = [[y := f(x), x/y] for x in range(5)] ''' expected_ast = ast.parse(source) diff --git a/test/test_bind_names.py b/test/test_bind_names.py index 87bbc447..2137dab4 100644 --- a/test/test_bind_names.py +++ b/test/test_bind_names.py @@ -1180,7 +1180,7 @@ class LazyList: try: pass except Exception as MyNonLocal: - pass + pass ''' @@ -1237,7 +1237,7 @@ class LazyList: MyAttribute = MyNonLocal match Blah: case MyNonLocal: - pass + pass ''' expected_namespaces = ''' @@ -1293,7 +1293,7 @@ class LazyList: MyAttribute = MyNonLocal match Blah: case [*MyNonLocal]: - pass + pass ''' expected_namespaces = ''' @@ -1349,7 +1349,7 @@ class LazyList: MyAttribute = MyNonLocal match Blah: case {**MyNonLocal}: - pass + pass ''' expected_namespaces = ''' diff --git a/test/test_combine_imports.py b/test/test_combine_imports.py index 6ed2d4cf..2506b51b 100644 --- a/test/test_combine_imports.py +++ b/test/test_combine_imports.py @@ -57,7 +57,7 @@ def test_import_from(): from builtins import help import collections from collections import abc''' - expected = '''from builtins import dir, help + expected = '''from builtins import dir, help import collections from collections import abc''' diff --git a/test/test_hoist_literals.py b/test/test_hoist_literals.py index 317c8b60..d78214dd 100644 --- a/test/test_hoist_literals.py +++ b/test/test_hoist_literals.py @@ -331,7 +331,7 @@ def a(): for i in (a for a in 'Hello'): pass for i in (a for a in 'World'): - pass + pass return 'World' def c(): return 'Hello' @@ -345,7 +345,7 @@ def a(): for i in (a for a in A): pass for i in (a for a in B): - pass + pass return B def c(): return A @@ -363,7 +363,7 @@ def a(): for i in [a for a in 'Hello']: pass for i in [a for a in 'World']: - pass + pass return 'World' def c(): return 'Hello' @@ -377,7 +377,7 @@ def a(): for i in [a for a in A]: pass for i in [a for a in B]: - pass + pass return B def c(): return A @@ -398,7 +398,7 @@ def a(): for i in {a: a for a in 'Hello'}: pass for i in {a: a for a in 'World'}: - pass + pass return 'World' def c(): return 'Hello' @@ -412,7 +412,7 @@ def a(): for i in {a: a for a in A}: pass for i in {a: a for a in B}: - pass + pass return B def c(): return A @@ -432,7 +432,7 @@ class a: def a(): for i in {a for a in 'Hello' + 'Hello' + 'World'}: pass - return 'World' + return 'World' def c(): return 'World' ''' @@ -443,7 +443,7 @@ class a: def a(): B = 'Hello' for i in {a for a in B + B + A}: - pass + pass return A def c(): return A diff --git a/test/test_match.py b/test/test_match.py index 7a5564b1..9b36a8c6 100644 --- a/test/test_match.py +++ b/test/test_match.py @@ -20,7 +20,7 @@ def test_pep635_unparse(): match node: case BinOp("+", a, BinOp("*", b, c)): - pass + pass match json_pet: case {"type": "cat", "name": name, "pattern": pattern}: @@ -314,7 +314,7 @@ def test_match_unparse(): match a: case 0|(0|0): pass - case (0|0)|0: pass + case (0|0)|0: pass case 0|0|0: pass match (lambda: a)(): @@ -322,7 +322,7 @@ def test_match_unparse(): match a:= h: case [action, obj]:pass - case {**rest}: pass + case {**rest}: pass ''' expected_ast = ast.parse(source) diff --git a/test/test_match_rename.py b/test/test_match_rename.py index d9349918..20f090a9 100644 --- a/test/test_match_rename.py +++ b/test/test_match_rename.py @@ -54,7 +54,7 @@ def func(): case hello: pass match 'hello' + 'hello': - case 'hello': pass + case 'hello': pass ''' expected = ''' B='hello' @@ -66,7 +66,7 @@ def C(): case hello: pass match B + B: - case 'hello': pass + case 'hello': pass ''' expected_ast = ast.parse(expected) @@ -105,7 +105,7 @@ def func(expensive_rename): case None: pass match B + B + B: - case 'hello': pass + case 'hello': pass ''' expected_ast = ast.parse(expected) @@ -125,8 +125,8 @@ def func(expensive_rename): hello=0 match None: case None if hello + hello + hello + hello: pass - case None if expensive_rename: pass - case 'hello' if 'hello' + 'hello' + 'hello' + 'hello': pass + case None if expensive_rename: pass + case 'hello' if 'hello' + 'hello' + 'hello' + 'hello': pass ''' expected = ''' match None: @@ -138,7 +138,7 @@ def func(expensive_rename): match None: case None if A + A + A + A: pass case None if expensive_rename: pass - case 'hello' if B + B + B + B: pass + case 'hello' if B + B + B + B: pass ''' expected_ast = ast.parse(expected) @@ -154,14 +154,14 @@ def test_rename_guard_global(): sausage=0 match None: case None if sausage + sausage + sausage + sausage: pass - case 'hello' if 'hello' + 'hello' + 'hello' + 'hello': pass + case 'hello' if 'hello' + 'hello' + 'hello' + 'hello': pass def func(expensive_rename): hello=0 match None: case None if hello + hello + hello + hello: pass - case None if expensive_rename: pass - case 'hello' if 'hello' + 'hello' + 'hello' + 'hello': pass + case None if expensive_rename: pass + case 'hello' if 'hello' + 'hello' + 'hello' + 'hello': pass ''' expected = ''' @@ -169,14 +169,14 @@ def func(expensive_rename): B=0 match None: case None if B + B + B + B: pass - case 'hello' if A + A + A + A: pass + case 'hello' if A + A + A + A: pass def C(expensive_rename): hello=0 match None: case None if hello + hello + hello + hello: pass - case None if expensive_rename: pass - case 'hello' if A + A + A + A: pass + case None if expensive_rename: pass + case 'hello' if A + A + A + A: pass ''' expected_ast = ast.parse(expected) @@ -197,11 +197,11 @@ def func(expensive_rename): hello=0 match None: case None: hello + hello + hello + hello - case None: expensive_rename + case None: expensive_rename ''' expected = ''' -sausage=0 +sausage=0 match None: case None: sausage + sausage + sausage + sausage @@ -209,7 +209,7 @@ def func(expensive_rename): A=0 match None: case None: A + A + A + A - case None: expensive_rename + case None: expensive_rename ''' expected_ast = ast.parse(expected) @@ -222,7 +222,7 @@ def test_rename_body_global(): pytest.skip('Match statement not in python < 3.10') source = ''' -sausage=0 +sausage=0 match None: case None: sausage + sausage + sausage + sausage @@ -230,7 +230,7 @@ def func(expensive_rename): hello=0 match None: case None: hello + hello + hello + hello - case None: expensive_rename + case None: expensive_rename ''' expected = ''' @@ -242,7 +242,7 @@ def B(expensive_rename): hello=0 match None: case None: hello + hello + hello + hello - case None: expensive_rename + case None: expensive_rename ''' expected_ast = ast.parse(expected) @@ -263,7 +263,7 @@ class Global: pass case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass def func(expensive_rename): class Local: pass @@ -271,11 +271,11 @@ class Local: pass match None: case expensive_rename(a, b) if a: b case Global(d, e) if d: e - case Local(f, g) if f: g + case Local(f, g) if f: g case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass ''' expected = ''' @@ -287,7 +287,7 @@ class Global: pass case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass def func(expensive_rename): class A: pass @@ -299,7 +299,7 @@ class A: pass case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass ''' expected_ast = ast.parse(expected) @@ -319,7 +319,7 @@ class Global: pass case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass def func(expensive_rename): class Local: pass @@ -327,11 +327,11 @@ class Local: pass match None: case expensive_rename(a, b) if a: b case Global(d, e) if d: e - case Local(f, g) if f: g + case Local(f, g) if f: g case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass ''' expected = ''' @@ -342,7 +342,7 @@ class A: pass case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass def D(expensive_rename): class Local: pass @@ -354,7 +354,7 @@ class Local: pass case ['hello', 'hello', 'hello', 'hello']: pass case [None, None, None, None]: pass case [True, True, True, True]: pass - case [False, False, False, False]: pass + case [False, False, False, False]: pass ''' expected_ast = ast.parse(expected) diff --git a/test/test_nonlocal.py b/test/test_nonlocal.py index 53e8c344..15af2758 100644 --- a/test/test_nonlocal.py +++ b/test/test_nonlocal.py @@ -17,7 +17,7 @@ def inner(): rename_me = 'inner' inner() - rename_me = False + rename_me = False outer() return rename_me diff --git a/test/test_remove_annotations.py b/test/test_remove_annotations.py index 18784bfd..d1263c56 100644 --- a/test/test_remove_annotations.py +++ b/test/test_remove_annotations.py @@ -335,7 +335,7 @@ class Dummy(TypedDict): class Dummy(HypedDict): myfield: 0 - mysecondfile: 0 + mysecondfile: 0 class Dummy(typing.TypedDict): myfield: int diff --git a/test/test_remove_assert.py b/test/test_remove_assert.py index 26fad451..c4543a1f 100644 --- a/test/test_remove_assert.py +++ b/test/test_remove_assert.py @@ -57,13 +57,13 @@ def test_remove_if_line(): def test_remove_suite(): - source = '''if True: + source = '''if True: + assert False + a=1 assert False - a=1 - assert False return None''' expected = '''if True: - a=1 + a=1 return None''' expected_ast = ast.parse(expected) diff --git a/test/test_remove_debug.py b/test/test_remove_debug.py index 59c6b01f..f15fc467 100644 --- a/test/test_remove_debug.py +++ b/test/test_remove_debug.py @@ -49,13 +49,13 @@ def test_remove_if_empty(): def test_remove_suite(): - source = '''if True: + source = '''if True: + if __debug__: pass + a=1 if __debug__: pass - a=1 - if __debug__: pass return None''' expected = '''if True: - a=1 + a=1 return None''' expected_ast = ast.parse(expected) @@ -124,13 +124,13 @@ def test_remove_truthy_debug(condition): if ''' + condition + ''': value += 1 -print(value) +print(value) ''' expected = ''' value = 10 -print(value) +print(value) ''' expected_ast = ast.parse(expected) @@ -157,7 +157,7 @@ def test_no_remove_falsy_debug(condition): if ''' + condition + ''': value += 1 -print(value) +print(value) ''' expected = source diff --git a/test/test_remove_pass.py b/test/test_remove_pass.py index 58887258..ba74af83 100644 --- a/test/test_remove_pass.py +++ b/test/test_remove_pass.py @@ -57,13 +57,13 @@ def test_remove_if_line(): def test_remove_suite(): - source = '''if True: + source = '''if True: + pass + a=1 pass - a=1 - pass return None''' expected = '''if True: - a=1 + a=1 return None''' expected_ast = ast.parse(expected) diff --git a/test/test_rename_locals.py b/test/test_rename_locals.py index ef9aa321..6be8f4f3 100644 --- a/test/test_rename_locals.py +++ b/test/test_rename_locals.py @@ -84,26 +84,26 @@ def mymethod4(self, a): return self, a @staticmethod def mystatic(cls): return cls - @staticmethod + @staticmethod def mystatic(asdfghjkl): return asdfghjkl - @staticmethod + @staticmethod def mystatic(): return 'No cls' @classmethod def mystatic(cls): return cls - @classmethod + @classmethod def mystatic(asdfghjkl): return asdfghjkl - @classmethod + @classmethod def mystatic(): return 'No cls' @unknown_decorator def unknown(self): return self - @unknown_decorator + @unknown_decorator def unknown(qwertyuiop): return qwertyuiop - @unknown_decorator + @unknown_decorator def unknown(self, arg): return self, arg - @unknown_decorator - def unknown(): return 'No arg' + @unknown_decorator + def unknown(): return 'No arg' ''' expected = ''' @@ -115,26 +115,26 @@ def mymethod4(A, a): return A, a @staticmethod def mystatic(cls): return cls - @staticmethod + @staticmethod def mystatic(asdfghjkl): return asdfghjkl - @staticmethod + @staticmethod def mystatic(): return 'No cls' @classmethod def mystatic(A): return A - @classmethod + @classmethod def mystatic(A): return A - @classmethod + @classmethod def mystatic(): return 'No cls' @unknown_decorator def unknown(self): return self - @unknown_decorator + @unknown_decorator def unknown(qwertyuiop): return qwertyuiop - @unknown_decorator + @unknown_decorator def unknown(self, arg): return self, arg - @unknown_decorator - def unknown(): return 'No arg' + @unknown_decorator + def unknown(): return 'No arg' ''' expected_ast = ast.parse(expected) @@ -161,7 +161,7 @@ class TestClass(): def mymethod(C, arg, *A, **B): return A, B @classmethod - def mymethod(C, arg, *A, **B): return A, B + def mymethod(C, arg, *A, **B): return A, B ''' expected_ast = ast.parse(expected) @@ -262,7 +262,7 @@ def test_rename_long_arg(): source = ''' def f(this_is_my_long_argument_name): print(this_is_my_long_argument_name) - print(this_is_my_long_argument_name) + print(this_is_my_long_argument_name) ''' expected = ''' def f(this_is_my_long_argument_name): @@ -282,18 +282,18 @@ def f(a): print(a) print(a) print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) - print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) + print(a) ''' expected_ast = ast.parse(source) @@ -308,7 +308,7 @@ def f(aa): print(aa) print(aa) print(aa) - print(aa) + print(aa) ''' expected = ''' def f(aa): @@ -317,7 +317,7 @@ def f(aa): print(A) print(A) print(A) - print(A) + print(A) ''' expected_ast = ast.parse(expected) @@ -327,7 +327,7 @@ def f(aa): def test_no_rename_lambda_arg(): source = ''' -lambda my_argument: f(my_argument + my_argument + my_argument) +lambda my_argument: f(my_argument + my_argument + my_argument) ''' expected_ast = ast.parse(source) @@ -337,11 +337,11 @@ def test_no_rename_lambda_arg(): def test_rename_lambda_stararg(): source = ''' -lambda *args, **kwargs: f(args, kwargs) +lambda *args, **kwargs: f(args, kwargs) ''' expected = ''' -lambda *A, **B: f(A, B) +lambda *A, **B: f(A, B) ''' expected_ast = ast.parse(expected) @@ -354,11 +354,11 @@ def test_python3_listcomp_scope(): pytest.skip('No list comprehension scope in python < 3.0') source = ''' -[a for a in mylist] +[a for a in mylist] ''' expected = ''' -[A for A in mylist] +[A for A in mylist] ''' expected_ast = ast.parse(expected) @@ -371,17 +371,17 @@ def test_python2_listcomp_scope(): pytest.skip('list comprehension scope in python >= 3.0') source = ''' -[a for a in mylist] +[a for a in mylist] def t(): a = True - [a for a in mylist] + [a for a in mylist] ''' expected = ''' -[a for a in mylist] +[a for a in mylist] def t(): A = True - [A for A in mylist] + [A for A in mylist] ''' expected_ast = ast.parse(expected) @@ -405,7 +405,7 @@ def f(*A,**B):pass def test_multiple_args(): source = ''' def f(hello, hello): - print(hello + hello) + print(hello + hello) ''' expected = ''' def f(hello, hello): diff --git a/test/test_type_param_defaults.py b/test/test_type_param_defaults.py index 07234573..a63c25f2 100644 --- a/test/test_type_param_defaults.py +++ b/test/test_type_param_defaults.py @@ -6,6 +6,7 @@ from python_minifier import unparse from python_minifier.ast_compare import compare_ast + # There are bizarrely few examples of this, some in the PEP are even syntax errors def test_pep696():