diff --git a/tests/aliases/test_xexec.py b/tests/aliases/test_xexec.py index 46ecdc7ca..b94ec6033 100644 --- a/tests/aliases/test_xexec.py +++ b/tests/aliases/test_xexec.py @@ -38,7 +38,7 @@ def test_command_not_found(monkeypatch): assert xexec([command]) == ( None, - f"xonsh: exec: file not found: {dummy_error_msg}: {command}" "\n", + f"xonsh: exec: file not found: {dummy_error_msg}: {command}\n", 1, ) diff --git a/tests/built_ins/test_wizard.py b/tests/built_ins/test_wizard.py index 300883fd9..eb543b356 100644 --- a/tests/built_ins/test_wizard.py +++ b/tests/built_ins/test_wizard.py @@ -19,7 +19,7 @@ TREE1 = Question("wakka?", {"jawaka": Pass()}) def test_pretty_format_tree0(): - exp = "Wizard(children=[\n" " Pass(),\n" " Message('yo')\n" "])" + exp = "Wizard(children=[\n Pass(),\n Message('yo')\n])" obs = PrettyFormatter(TREE0).visit() assert exp == obs assert exp == str(TREE0) @@ -27,14 +27,7 @@ def test_pretty_format_tree0(): def test_pretty_format_tree1(): - exp = ( - "Question(\n" - " question='wakka?',\n" - " responses={\n" - " 'jawaka': Pass()\n" - " }\n" - ")" - ) + exp = "Question(\n question='wakka?',\n responses={\n 'jawaka': Pass()\n }\n)" obs = PrettyFormatter(TREE1).visit() assert exp == obs assert exp == str(TREE1) diff --git a/tests/history/test_history_json.py b/tests/history/test_history_json.py index 0b1947e61..af39d32db 100644 --- a/tests/history/test_history_json.py +++ b/tests/history/test_history_json.py @@ -408,7 +408,7 @@ def history_files_list(gen_count) -> (float, int, str, int): # first day in sec + #days * 24hr + #hr * 60min + # sec * 60sec + sec= sec to date. HF_FIRST_DAY + (((((i * 24) + 9) * 60) + 0) * 60) + 0, # mod dt, 100, - f".argle/xonsh-{2*i:05n}.json", + f".argle/xonsh-{2 * i:05n}.json", 10000, ) ) @@ -417,7 +417,7 @@ def history_files_list(gen_count) -> (float, int, str, int): # first day in sec + #days * 24hr + #hr * 60min + # sec * 60sec + sec= sec to date. HF_FIRST_DAY + (((((i * 24) + 23) * 60) + 0) * 60) + 0, # mod dt, 50, - f".argle/xonsh-{2*i+1:05n}.json", + f".argle/xonsh-{2 * i + 1:05n}.json", 2500, ) ) diff --git a/tests/parsers/test_lexer.py b/tests/parsers/test_lexer.py index 21c3a01c4..f81d0b0a8 100644 --- a/tests/parsers/test_lexer.py +++ b/tests/parsers/test_lexer.py @@ -246,11 +246,7 @@ def test_not_really_or_pre_post(): def test_subproc_line_cont_space(): - inp = ( - "![echo --option1 value1 \\\n" - " --option2 value2 \\\n" - " --optionZ valueZ]" - ) + inp = "![echo --option1 value1 \\\n --option2 value2 \\\n --optionZ valueZ]" exp = [ ("BANG_LBRACKET", "![", 0), ("NAME", "echo", 2), @@ -278,11 +274,7 @@ def test_subproc_line_cont_space(): def test_subproc_line_cont_nospace(): - inp = ( - "![echo --option1 value1\\\n" - " --option2 value2\\\n" - " --optionZ valueZ]" - ) + inp = "![echo --option1 value1\\\n --option2 value2\\\n --optionZ valueZ]" exp = [ ("BANG_LBRACKET", "![", 0), ("NAME", "echo", 2), diff --git a/tests/parsers/test_parser.py b/tests/parsers/test_parser.py index 971855fb3..ecc253af2 100644 --- a/tests/parsers/test_parser.py +++ b/tests/parsers/test_parser.py @@ -1736,7 +1736,7 @@ def test_if_switch(check_stmts): def test_if_switch_elif1_else(check_stmts): - check_stmts("x = 42\nif x == 1:\n pass\n" "elif x == 2:\n pass\nelse:\n pass") + check_stmts("x = 42\nif x == 1:\n pass\nelif x == 2:\n pass\nelse:\n pass") def test_if_switch_elif2_else(check_stmts): @@ -1774,7 +1774,7 @@ def test_for_idx(check_stmts): def test_for_zip_idx(check_stmts): - check_stmts('x = [42]\nfor x[0], y in zip(range(6), "123456"):\n' " pass") + check_stmts('x = [42]\nfor x[0], y in zip(range(6), "123456"):\n pass') def test_for_attr(check_stmts): @@ -1843,7 +1843,7 @@ def test_try_except_t_u_as_e(check_stmts): def test_try_except_t_except_u(check_stmts): check_stmts( - "try:\n pass\nexcept TypeError:\n pass\n" "except SyntaxError as f:\n pass", + "try:\n pass\nexcept TypeError:\n pass\nexcept SyntaxError as f:\n pass", False, ) @@ -1857,9 +1857,7 @@ def test_try_except_finally(check_stmts): def test_try_except_else_finally(check_stmts): - check_stmts( - "try:\n pass\nexcept:\n pass\nelse:\n pass" "\nfinally: pass", False - ) + check_stmts("try:\n pass\nexcept:\n pass\nelse:\n pass\nfinally: pass", False) def test_try_finally(check_stmts): @@ -2118,7 +2116,7 @@ def test_decorator_dot_dot_call_args(check_stmts): def test_broken_prompt_func(check_stmts): - code = "def prompt():\n" " return '{user}'.format(\n" " user='me')\n" + code = "def prompt():\n return '{user}'.format(\n user='me')\n" check_stmts(code, False) @@ -2134,12 +2132,7 @@ def test_class_with_methods(check_stmts): def test_nested_functions(check_stmts): - code = ( - "def test(x):\n" - " def test2(y):\n" - " return y+x\n" - " return test2\n" - ) + code = "def test(x):\n def test2(y):\n return y+x\n return test2\n" check_stmts(code, False) @@ -2519,7 +2512,7 @@ def test_bang_git_quotes_space(check_xonsh_ast): def test_bang_git_two_quotes_space(check_xonsh): check_xonsh( {}, - '![git commit -am "wakka jawaka"]\n' '![git commit -am "flock jawaka"]\n', + '![git commit -am "wakka jawaka"]\n![git commit -am "flock jawaka"]\n', False, ) @@ -2612,7 +2605,7 @@ def test_git_quotes_space(check_xonsh_ast): def test_git_two_quotes_space(check_xonsh): check_xonsh( {}, - '$[git commit -am "wakka jawaka"]\n' '$[git commit -am "flock jawaka"]\n', + '$[git commit -am "wakka jawaka"]\n$[git commit -am "flock jawaka"]\n', False, ) @@ -2959,7 +2952,7 @@ WITH_BANG_RAWSUITES = [ "pass\n", "x = 42\ny = 12\n", 'export PATH="yo:momma"\necho $PATH\n', - ("with q as t:\n" " v = 10\n" "\n"), + ("with q as t:\n v = 10\n\n"), ( "with q as t:\n" " v = 10\n" diff --git a/tests/test_completion_context.py b/tests/test_completion_context.py index 9b77ab7cd..3d820c1a5 100644 --- a/tests/test_completion_context.py +++ b/tests/test_completion_context.py @@ -288,7 +288,7 @@ def test_partial_string_arg(commandline, context): assert_match(partial_commandline, partial_context, is_main_command=True) -CONT = "\\" "\n" +CONT = "\\\n" @pytest.mark.parametrize( diff --git a/tests/test_contexts.py b/tests/test_contexts.py index 578fbf2d3..045a2b0bc 100644 --- a/tests/test_contexts.py +++ b/tests/test_contexts.py @@ -8,7 +8,7 @@ from xonsh.contexts import Block, Functor # helpers # -X1_WITH = "x = 1\n" "with! Block() as b:\n" +X1_WITH = "x = 1\nwith! Block() as b:\n" SIMPLE_WITH = "with! Block() as b:\n" FUNC_WITH = ( "x = 1\n" @@ -68,7 +68,7 @@ def block_checks_func(name, glbs, body, obsg=None, obsl=None): def test_block_noexec(xonsh_execer_exec): - s = "x = 1\n" "with! Block():\n" " x += 42\n" + s = "x = 1\nwith! Block():\n x += 42\n" glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) assert 1 == glbs["x"] @@ -83,7 +83,7 @@ def test_block_oneline(xonsh_execer_exec): def test_block_manylines(xonsh_execer_exec): - body = " ![echo wow mom]\n" "# bad place for a comment\n" " x += 42" + body = " ![echo wow mom]\n# bad place for a comment\n x += 42" s = X1_WITH + body glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -92,7 +92,7 @@ def test_block_manylines(xonsh_execer_exec): def test_block_leading_comment(xonsh_execer_exec): # leading comments do not show up in block lines - body = " # I am a leading comment\n" " x += 42\n" + body = " # I am a leading comment\n x += 42\n" s = X1_WITH + body glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -101,7 +101,7 @@ def test_block_leading_comment(xonsh_execer_exec): def test_block_trailing_comment(xonsh_execer_exec): # trailing comments show up in block lines - body = " x += 42\n" " # I am a trailing comment\n" + body = " x += 42\n # I am a trailing comment\n" s = X1_WITH + body glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -109,7 +109,7 @@ def test_block_trailing_comment(xonsh_execer_exec): def test_block_trailing_line_continuation(xonsh_execer_exec): - body = " x += \\\n" " 42\n" + body = " x += \\\n 42\n" s = X1_WITH + body glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -117,7 +117,7 @@ def test_block_trailing_line_continuation(xonsh_execer_exec): def test_block_trailing_close_paren(xonsh_execer_exec): - body = ' x += int("42"\n' " )\n" + body = ' x += int("42"\n )\n' s = X1_WITH + body glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -138,7 +138,7 @@ def test_block_trailing_close_many(xonsh_execer_exec): def test_block_trailing_triple_string(xonsh_execer_exec): - body = ' x = """This\n' "is\n" '"probably"\n' "'not' what I meant.\n" '"""\n' + body = ' x = """This\nis\n"probably"\n\'not\' what I meant.\n"""\n' s = SIMPLE_WITH + body glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -154,7 +154,7 @@ def test_block_func_oneline(xonsh_execer_exec): def test_block_func_manylines(xonsh_execer_exec): - body = " ![echo wow mom]\n" "# bad place for a comment\n" " x += 42\n" + body = " ![echo wow mom]\n# bad place for a comment\n x += 42\n" s = FUNC_WITH.format(body=body) glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -163,7 +163,7 @@ def test_block_func_manylines(xonsh_execer_exec): def test_block_func_leading_comment(xonsh_execer_exec): # leading comments do not show up in block lines - body = " # I am a leading comment\n" " x += 42\n" + body = " # I am a leading comment\n x += 42\n" s = FUNC_WITH.format(body=body) glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -172,7 +172,7 @@ def test_block_func_leading_comment(xonsh_execer_exec): def test_block_func_trailing_comment(xonsh_execer_exec): # trailing comments show up in block lines - body = " x += 42\n" " # I am a trailing comment\n" + body = " x += 42\n # I am a trailing comment\n" s = FUNC_WITH.format(body=body) glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -180,7 +180,7 @@ def test_block_func_trailing_comment(xonsh_execer_exec): def test_blockfunc__trailing_line_continuation(xonsh_execer_exec): - body = " x += \\\n" " 42\n" + body = " x += \\\n 42\n" s = FUNC_WITH.format(body=body) glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -188,7 +188,7 @@ def test_blockfunc__trailing_line_continuation(xonsh_execer_exec): def test_block_func_trailing_close_paren(xonsh_execer_exec): - body = ' x += int("42"\n' " )\n" + body = ' x += int("42"\n )\n' s = FUNC_WITH.format(body=body) glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -209,7 +209,7 @@ def test_block_func_trailing_close_many(xonsh_execer_exec): def test_block_func_trailing_triple_string(xonsh_execer_exec): - body = ' x = """This\n' "is\n" '"probably"\n' "'not' what I meant.\n" '"""\n' + body = ' x = """This\nis\n"probably"\n\'not\' what I meant.\n"""\n' s = FUNC_WITH.format(body=body) glbs = {"Block": Block} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -220,11 +220,11 @@ def test_block_func_trailing_triple_string(xonsh_execer_exec): # Functor tests # -X2_WITH = "{var} = 1\n" "with! Functor() as f:\n" "{body}" "{var} += 1\n" "{calls}\n" +X2_WITH = "{var} = 1\nwith! Functor() as f:\n{body}{var} += 1\n{calls}\n" def test_functor_oneline_onecall_class(xonsh_execer_exec): - body = " global y\n" " y += 42\n" + body = " global y\n y += 42\n" calls = "f()" s = X2_WITH.format(body=body, calls=calls, var="y") glbs = {"Functor": Functor} @@ -233,7 +233,7 @@ def test_functor_oneline_onecall_class(xonsh_execer_exec): def test_functor_oneline_onecall_func(xonsh_execer_exec): - body = " global z\n" " z += 42\n" + body = " global z\n z += 42\n" calls = "f.func()" s = X2_WITH.format(body=body, calls=calls, var="z") glbs = {"Functor": Functor} @@ -242,7 +242,7 @@ def test_functor_oneline_onecall_func(xonsh_execer_exec): def test_functor_oneline_onecall_both(xonsh_execer_exec): - body = " global x\n" " x += 42\n" + body = " global x\n x += 42\n" calls = "f()\nf.func()" s = X2_WITH.format(body=body, calls=calls, var="x") glbs = {"Functor": Functor} @@ -250,7 +250,7 @@ def test_functor_oneline_onecall_both(xonsh_execer_exec): block_checks_glb("f", glbs, body, {"x": 86}) -XA_WITH = "x = [1]\n" "with! Functor() as f:\n" "{body}" "x.append(2)\n" "{calls}\n" +XA_WITH = "x = [1]\nwith! Functor() as f:\n{body}x.append(2)\n{calls}\n" def test_functor_oneline_append(xonsh_execer_exec): @@ -264,7 +264,7 @@ def test_functor_oneline_append(xonsh_execer_exec): def test_functor_return(xonsh_execer_exec): body = " x = 42" - t = "res = 0\n" 'with! Functor(rtn="x") as f:\n' "{body}\n" "res = f()\n" + t = 'res = 0\nwith! Functor(rtn="x") as f:\n{body}\nres = f()\n' s = t.format(body=body) glbs = {"Functor": Functor} xonsh_execer_exec(s, glbs=glbs, locs=None) @@ -273,12 +273,7 @@ def test_functor_return(xonsh_execer_exec): def test_functor_args(xonsh_execer_exec): body = " x = 42 + a" - t = ( - "res = 0\n" - 'with! Functor(args=("a",), rtn="x") as f:\n' - "{body}\n" - "res = f(2)\n" - ) + t = 'res = 0\nwith! Functor(args=("a",), rtn="x") as f:\n{body}\nres = f(2)\n' s = t.format(body=body) glbs = {"Functor": Functor} xonsh_execer_exec(s, glbs=glbs, locs=None) diff --git a/tests/test_dirstack.py b/tests/test_dirstack.py index e70d10c8a..9769fbd2e 100644 --- a/tests/test_dirstack.py +++ b/tests/test_dirstack.py @@ -58,9 +58,9 @@ def test_cdpath_expansion(xession): for d in test_dirs: if not os.path.exists(d): os.mkdir(d) - assert os.path.exists( - dirstack._try_cdpath(d) - ), f"dirstack._try_cdpath: could not resolve {d}" + assert os.path.exists(dirstack._try_cdpath(d)), ( + f"dirstack._try_cdpath: could not resolve {d}" + ) finally: for d in test_dirs: if os.path.exists(d): diff --git a/tests/test_dirstack_unc.py b/tests/test_dirstack_unc.py index 2e792a4aa..21ce096e1 100644 --- a/tests/test_dirstack_unc.py +++ b/tests/test_dirstack_unc.py @@ -150,9 +150,9 @@ def test_uncpushd_push_to_same_share(xession, shares_setup): assert len(DIRSTACK) == 2 dirstack.popd([]) - assert os.path.isdir( - TEMP_DRIVE[0] + "\\" - ), "Temp drive not unmapped till last reference removed" + assert os.path.isdir(TEMP_DRIVE[0] + "\\"), ( + "Temp drive not unmapped till last reference removed" + ) dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0 diff --git a/tests/test_environ.py b/tests/test_environ.py index 4880c8619..4fa4cad31 100644 --- a/tests/test_environ.py +++ b/tests/test_environ.py @@ -370,9 +370,9 @@ def test_lscolors_events(key_in, old_in, new_in, test, xession): @xession.builtins.events.on_lscolors_change def handler(key, oldvalue, newvalue, **kwargs): nonlocal old_in, new_in, key_in, event_fired - assert ( - key == key_in and oldvalue == old_in and newvalue == new_in - ), "Old and new event values match" + assert key == key_in and oldvalue == old_in and newvalue == new_in, ( + "Old and new event values match" + ) event_fired = True xession.env["LS_COLORS"] = lsc diff --git a/tests/test_execer.py b/tests/test_execer.py index 5e367559d..12454c445 100644 --- a/tests/test_execer.py +++ b/tests/test_execer.py @@ -60,12 +60,12 @@ def test_echo_star_with_semi(xonsh_execer_parse): def test_simple_func(xonsh_execer_parse): - code = "def prompt():\n" " return '{user}'.format(user='me')\n" + code = "def prompt():\n return '{user}'.format(user='me')\n" assert xonsh_execer_parse(code) def test_lookup_alias(xonsh_execer_parse): - code = "def foo(a, s=None):\n" ' return "bar"\n' "@(foo)\n" + code = 'def foo(a, s=None):\n return "bar"\n@(foo)\n' assert xonsh_execer_parse(code) @@ -75,12 +75,12 @@ def test_lookup_anon_alias(xonsh_execer_parse): def test_simple_func_broken(xonsh_execer_parse): - code = "def prompt():\n" " return '{user}'.format(\n" " user='me')\n" + code = "def prompt():\n return '{user}'.format(\n user='me')\n" assert xonsh_execer_parse(code) def test_bad_indent(xonsh_execer_parse): - code = "if True:\n" "x = 1\n" + code = "if True:\nx = 1\n" with pytest.raises(SyntaxError): xonsh_execer_parse(code) @@ -104,17 +104,17 @@ def test_bad_rhs_subproc(xonsh_execer_parse): def test_indent_with_empty_line(xonsh_execer_parse): - code = "if True:\n" "\n" " some_command for_sub_process_mode\n" + code = "if True:\n\n some_command for_sub_process_mode\n" assert xonsh_execer_parse(code) def test_command_in_func(xonsh_execer_parse): - code = "def f():\n" " echo hello\n" + code = "def f():\n echo hello\n" assert xonsh_execer_parse(code) def test_command_in_func_with_comment(xonsh_execer_parse): - code = "def f():\n" " echo hello # comment\n" + code = "def f():\n echo hello # comment\n" assert xonsh_execer_parse(code) diff --git a/tests/test_foreign_shells.py b/tests/test_foreign_shells.py index c1f63b3e6..8365f1bbb 100644 --- a/tests/test_foreign_shells.py +++ b/tests/test_foreign_shells.py @@ -11,14 +11,7 @@ from xonsh.pytest.tools import skip_if_on_unix, skip_if_on_windows def test_parse_env(): exp = {"X": "YES", "Y": "NO"} - s = ( - "some garbage\n" - "__XONSH_ENV_BEG__\n" - "Y=NO\n" - "X=YES\n" - "__XONSH_ENV_END__\n" - "more filth" - ) + s = "some garbage\n__XONSH_ENV_BEG__\nY=NO\nX=YES\n__XONSH_ENV_END__\nmore filth" obs = parse_env(s) assert exp == obs diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 980a11846..a7ceed97f 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -759,9 +759,9 @@ def test_script(case): out, err, rtn = run_xonsh(script) out = out.replace("bash: no job control in this shell\n", "") if callable(exp_out): - assert exp_out( - out - ), f"CASE:\nscript=***\n{script}\n***,\nExpected: {exp_out!r},\nActual: {out!r}" + assert exp_out(out), ( + f"CASE:\nscript=***\n{script}\n***,\nExpected: {exp_out!r},\nActual: {out!r}" + ) else: assert exp_out == out assert exp_rtn == rtn @@ -1280,9 +1280,9 @@ echo f1f1f1 ; f ; echo f2f2f2 def test_aliases_print(case): cmd, match = case out, err, ret = run_xonsh(cmd=cmd, single_command=False) - assert re.match( - match, out, re.MULTILINE | re.DOTALL - ), f"\nFailed:\n```\n{cmd.strip()}\n```,\nresult: {out!r}\nexpected: {match!r}." + assert re.match(match, out, re.MULTILINE | re.DOTALL), ( + f"\nFailed:\n```\n{cmd.strip()}\n```,\nresult: {out!r}\nexpected: {match!r}." + ) @skip_if_on_windows @@ -1420,9 +1420,9 @@ def test_suspended_captured_process_pipeline(): cmd=None, stdin_cmd=stdin_cmd, interactive=True, single_command=False, timeout=5 ) match = ".*suspended=True.*" - assert re.match( - match, out, re.MULTILINE | re.DOTALL - ), f"\nFailed:\n```\n{stdin_cmd.strip()}\n```,\nresult: {out!r}\nexpected: {match!r}." + assert re.match(match, out, re.MULTILINE | re.DOTALL), ( + f"\nFailed:\n```\n{stdin_cmd.strip()}\n```,\nresult: {out!r}\nexpected: {match!r}." + ) @skip_if_on_windows @@ -1462,9 +1462,9 @@ def test_captured_subproc_is_not_affected_next_command(): single_command=False, timeout=10, ) - assert not re.match( - ".*FAIL_TEST.*", out, re.MULTILINE | re.DOTALL - ), "The second command after running captured subprocess shouldn't wait the end of the first one." + assert not re.match(".*FAIL_TEST.*", out, re.MULTILINE | re.DOTALL), ( + "The second command after running captured subprocess shouldn't wait the end of the first one." + ) @skip_if_on_windows diff --git a/tests/test_tools.py b/tests/test_tools.py index 49fcc6211..d97e7da43 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -511,18 +511,14 @@ mom""" ), # test from start ( - "echo --option1 value1 \\\n" - " --option2 value2 \\\n" - " --optionZ valueZ", + "echo --option1 value1 \\\n --option2 value2 \\\n --optionZ valueZ", 0, "echo --option1 value1 --option2 value2 --optionZ valueZ", 3, ), # test from second line ( - "echo --option1 value1 \\\n" - " --option2 value2 \\\n" - " --optionZ valueZ", + "echo --option1 value1 \\\n --option2 value2 \\\n --optionZ valueZ", 1, "echo --option1 value1 --option2 value2 --optionZ valueZ", 3, @@ -575,7 +571,7 @@ def test_is_balanced_parens(inp): assert obs -@pytest.mark.parametrize("inp", ["f(x.", "f(1,x." "f((1,10),x.y"]) +@pytest.mark.parametrize("inp", ["f(x.", "f(1,x.f((1,10),x.y"]) def test_is_not_balanced_parens(inp): obs = is_balanced(inp, "(", ")") assert not obs diff --git a/xonsh/aliases.py b/xonsh/aliases.py index 3c98b092c..1c1263329 100644 --- a/xonsh/aliases.py +++ b/xonsh/aliases.py @@ -944,7 +944,7 @@ def xexec_fn( except FileNotFoundError as e: return ( None, - f"xonsh: exec: file not found: {e.args[1]}: {command[0]}" "\n", + f"xonsh: exec: file not found: {e.args[1]}: {command[0]}\n", 1, ) @@ -1124,9 +1124,7 @@ def make_default_aliases(): def sudo(args): if len(args) < 1: - print( - "You need to provide an executable to run as " "Administrator." - ) + print("You need to provide an executable to run as Administrator.") return cmd = args[0] if locate_binary(cmd): diff --git a/xonsh/built_ins.py b/xonsh/built_ins.py index dbd9148c7..48d2bc9b3 100644 --- a/xonsh/built_ins.py +++ b/xonsh/built_ins.py @@ -373,7 +373,7 @@ def convert_macro_arg(raw_arg, kind, glbs, locs, *, name="", macroname="= 1: - msg = "{0}:{1}:{2}{3} - {4}\n" "{0}:{1}:{2}{3} + {5}" + msg = "{0}:{1}:{2}{3} - {4}\n{0}:{1}:{2}{3} + {5}" mstr = "" if maxcol is None else ":" + str(maxcol) msg = msg.format( self.filename, last_error_line, last_error_col, mstr, line, sbpline diff --git a/xonsh/foreign_shells.py b/xonsh/foreign_shells.py index ea72d92fe..e65fc6ba1 100644 --- a/xonsh/foreign_shells.py +++ b/xonsh/foreign_shells.py @@ -277,7 +277,7 @@ def foreign_shell_data( @lazyobject def ENV_RE(): - return re.compile("__XONSH_ENV_BEG__\n(.*)" "__XONSH_ENV_END__", flags=re.DOTALL) + return re.compile("__XONSH_ENV_BEG__\n(.*)__XONSH_ENV_END__", flags=re.DOTALL) @lazyobject @@ -298,9 +298,7 @@ def parse_env(s): @lazyobject def ALIAS_RE(): - return re.compile( - "__XONSH_ALIAS_BEG__\n(.*)" "__XONSH_ALIAS_END__", flags=re.DOTALL - ) + return re.compile("__XONSH_ALIAS_BEG__\n(.*)__XONSH_ALIAS_END__", flags=re.DOTALL) @lazyobject @@ -355,9 +353,7 @@ def parse_aliases(s, shell, sourcer=None, files=(), extra_args=()): @lazyobject def FUNCS_RE(): - return re.compile( - "__XONSH_FUNCS_BEG__\n(.+)\n" "__XONSH_FUNCS_END__", flags=re.DOTALL - ) + return re.compile("__XONSH_FUNCS_BEG__\n(.+)\n__XONSH_FUNCS_END__", flags=re.DOTALL) def parse_funcs(s, shell, sourcer=None, files=(), extra_args=()): diff --git a/xonsh/history/base.py b/xonsh/history/base.py index 97128771a..82fc96ef8 100644 --- a/xonsh/history/base.py +++ b/xonsh/history/base.py @@ -109,13 +109,11 @@ class History: ] else: raise TypeError( - "history indices must be integers " f"or slices, not {type(item)}" + f"history indices must be integers or slices, not {type(item)}" ) def __setitem__(self, *args): - raise PermissionError( - "You cannot change history! " "you can create new though." - ) + raise PermissionError("You cannot change history! you can create new though.") def append(self, cmd): """Append a command item into history. diff --git a/xonsh/history/diff_history.py b/xonsh/history/diff_history.py index 2be9ed3b4..80112edff 100644 --- a/xonsh/history/diff_history.py +++ b/xonsh/history/diff_history.py @@ -118,7 +118,7 @@ class HistoryDiffer: def header(self): """Computes a header string difference.""" - s = "{red}--- {aline}{reset}\n" "{green}+++ {bline}{reset}" + s = "{red}--- {aline}{reset}\n{green}+++ {bline}{reset}" s = s.format( aline=self._header_line(self.a), bline=self._header_line(self.b), diff --git a/xonsh/history/sqlite.py b/xonsh/history/sqlite.py index cfc59fd1a..631c22353 100644 --- a/xonsh/history/sqlite.py +++ b/xonsh/history/sqlite.py @@ -276,8 +276,7 @@ class SqliteHistoryGC(threading.Thread): hsize, units = envs.get("XONSH_HISTORY_SIZE") if units != "commands": print( - "sqlite backed history gc currently only supports " - '"commands" as units', + 'sqlite backed history gc currently only supports "commands" as units', file=sys.stderr, ) return diff --git a/xonsh/lib/inspectors.py b/xonsh/lib/inspectors.py index 0de3e1ea6..52e17b57a 100644 --- a/xonsh/lib/inspectors.py +++ b/xonsh/lib/inspectors.py @@ -668,7 +668,7 @@ class Inspector: if fname.endswith((".so", ".dll", ".pyd")): binary_file = True elif fname.endswith(""): - fname = "Dynamically generated function. " "No source code available." + fname = "Dynamically generated function. No source code available." out["file"] = fname # Docstrings only in detail 0 mode, since source contains them (we diff --git a/xonsh/parsers/ast.py b/xonsh/parsers/ast.py index 9f73d9630..c1e785a2a 100644 --- a/xonsh/parsers/ast.py +++ b/xonsh/parsers/ast.py @@ -481,7 +481,7 @@ class CtxAwareTransformer(NodeTransformer): increment_lineno(newnode, n=node.lineno - 1) newnode.col_offset = node.col_offset if self.debug_level >= 1: - msg = "{0}:{1}:{2}{3} - {4}\n" "{0}:{1}:{2}{3} + {5}" + msg = "{0}:{1}:{2}{3} - {4}\n{0}:{1}:{2}{3} + {5}" mstr = "" if maxcol is None else ":" + str(maxcol) msg = msg.format(self.filename, node.lineno, mincol, mstr, line, spline) print(msg, file=sys.stderr) diff --git a/xonsh/parsers/base.py b/xonsh/parsers/base.py index 239926d03..0882c964b 100644 --- a/xonsh/parsers/base.py +++ b/xonsh/parsers/base.py @@ -530,7 +530,7 @@ class BaseParser: def optfunc(self, p): p[0] = p[1] - optfunc.__doc__ = f"{rulename}_opt : empty\n" f" | {rulename}" + optfunc.__doc__ = f"{rulename}_opt : empty\n | {rulename}" optfunc.__name__ = "p_" + rulename + "_opt" setattr(self.__class__, optfunc.__name__, optfunc) @@ -543,7 +543,7 @@ class BaseParser: p[0] = p[1] if len(p) == 2 else p[1] + p[2] listfunc.__doc__ = ( - f"{rulename}_list : {rulename}\n" f" | {rulename}_list {rulename}" + f"{rulename}_list : {rulename}\n | {rulename}_list {rulename}" ) listfunc.__name__ = "p_" + rulename + "_list" setattr(self.__class__, listfunc.__name__, listfunc) diff --git a/xonsh/parsers/completion_context.py b/xonsh/parsers/completion_context.py index f296d37a8..fe02fb4a2 100644 --- a/xonsh/parsers/completion_context.py +++ b/xonsh/parsers/completion_context.py @@ -393,9 +393,9 @@ class CompletionContextParser: self.error = None try: - assert self.cursor_in_span( - slice(0, len(multiline_text)) - ), f"Bad cursor index: {cursor_index}" + assert self.cursor_in_span(slice(0, len(multiline_text))), ( + f"Bad cursor index: {cursor_index}" + ) context: Optional[CompletionContext] = self.parser.parse( input=multiline_text, lexer=self, debug=1 if self.debug else 0 @@ -440,9 +440,9 @@ class CompletionContextParser: continue lineno = tok.lineno - 1 # tok.lineno is 1-indexed - assert lineno < len( - self.line_indices - ), f"Invalid lexer state for token {tok} - bad lineno" + assert lineno < len(self.line_indices), ( + f"Invalid lexer state for token {tok} - bad lineno" + ) tok.lexpos = lexpos = self.line_indices[lineno] + tok.lexpos diff --git a/xonsh/parsers/v310.py b/xonsh/parsers/v310.py index b5ac4ce48..cb60f2ba6 100644 --- a/xonsh/parsers/v310.py +++ b/xonsh/parsers/v310.py @@ -269,9 +269,9 @@ class Parser(ThreeNineParser): if build_complex: # TODO raise syntax error instead (see reason in p_literal_expr_number_or_string_literal_list) - assert isinstance( - right.value, complex - ), "right part of complex literal must be imaginary" + assert isinstance(right.value, complex), ( + "right part of complex literal must be imaginary" + ) if negate_left_side: left = ast.UnaryOp(op=ast.USub(), operand=left, **loc) diff --git a/xonsh/platform.py b/xonsh/platform.py index 1fecfe451..57b0a5e62 100644 --- a/xonsh/platform.py +++ b/xonsh/platform.py @@ -507,7 +507,7 @@ def BASH_COMPLETIONS_DEFAULT(): ), os.path.join( git_for_windows_path(), - "mingw64\\share\\git\\completion\\" "git-completion.bash", + "mingw64\\share\\git\\completion\\git-completion.bash", ), ) else: diff --git a/xonsh/procs/jobs.py b/xonsh/procs/jobs.py index 1e7b6a922..0c41a33fa 100644 --- a/xonsh/procs/jobs.py +++ b/xonsh/procs/jobs.py @@ -115,7 +115,7 @@ def proc_untraced_waitpid(proc, hang, task=None, raise_child_process_error=False proc.signal = None info["signal"] = None - info["signal_name"] = f'{info["signal"]} {get_signal_name(info["signal"])}'.strip() + info["signal_name"] = f"{info['signal']} {get_signal_name(info['signal'])}".strip() return info diff --git a/xonsh/prompt/base.py b/xonsh/prompt/base.py index 23176f9b6..a4189159e 100644 --- a/xonsh/prompt/base.py +++ b/xonsh/prompt/base.py @@ -132,7 +132,7 @@ class PromptFormatter: try: return self.fields.pick(field) except Exception: # noqa - print(f"prompt: error: on field {field!r}" "", file=sys.stderr) + print(f"prompt: error: on field {field!r}", file=sys.stderr) xt.print_exception() value = f"{{BACKGROUND_RED}}{{ERROR:{field}}}{{RESET}}" return value diff --git a/xonsh/pytest/tools.py b/xonsh/pytest/tools.py index 116d34b85..8e9872d9e 100644 --- a/xonsh/pytest/tools.py +++ b/xonsh/pytest/tools.py @@ -105,29 +105,29 @@ class DummyHistory: def nodes_equal(x, y): __tracebackhide__ = True - assert type(x) is type( - y - ), f"Ast nodes do not have the same type: '{type(x)}' != '{type(y)}' " + assert type(x) is type(y), ( + f"Ast nodes do not have the same type: '{type(x)}' != '{type(y)}' " + ) if isinstance(x, ast.Constant): - assert ( - x.value == y.value - ), f"Constant ast nodes do not have the same value: {repr(x.value)} != {repr(y.value)}" + assert x.value == y.value, ( + f"Constant ast nodes do not have the same value: {repr(x.value)} != {repr(y.value)}" + ) if isinstance(x, (ast.Expr, ast.FunctionDef, ast.ClassDef)): - assert ( - x.lineno == y.lineno - ), f"Ast nodes do not have the same line number : {x.lineno} != {y.lineno}" - assert ( - x.col_offset == y.col_offset - ), f"Ast nodes do not have the same column offset number : {x.col_offset} != {y.col_offset}" + assert x.lineno == y.lineno, ( + f"Ast nodes do not have the same line number : {x.lineno} != {y.lineno}" + ) + assert x.col_offset == y.col_offset, ( + f"Ast nodes do not have the same column offset number : {x.col_offset} != {y.col_offset}" + ) for (xname, xval), (yname, yval) in zip(ast.iter_fields(x), ast.iter_fields(y)): - assert ( - xname == yname - ), f"Ast nodes field names differ : {xname} (of type {type(xval)}) != {yname} (of type {type(yval)})" + assert xname == yname, ( + f"Ast nodes field names differ : {xname} (of type {type(xval)}) != {yname} (of type {type(yval)})" + ) if isinstance(x, ast.Constant) and xname == "kind": continue - assert ( - type(xval) is type(yval) - ), f"Ast nodes fields differ : {xname} (of type {type(xval)}) != {yname} (of type {type(yval)})" + assert type(xval) is type(yval), ( + f"Ast nodes fields differ : {xname} (of type {type(xval)}) != {yname} (of type {type(yval)})" + ) for xchild, ychild in zip(ast.iter_child_nodes(x), ast.iter_child_nodes(y)): assert nodes_equal(xchild, ychild), "Ast node children differs" return True diff --git a/xonsh/shells/readline_shell.py b/xonsh/shells/readline_shell.py index 564b06787..e4d2f796d 100644 --- a/xonsh/shells/readline_shell.py +++ b/xonsh/shells/readline_shell.py @@ -577,7 +577,7 @@ class ReadlineShell(BaseShell, cmd.Cmd): line = self.singleline() except EOFError: if XSH.env.get("IGNOREEOF"): - self.stdout.write('Use "exit" to leave the shell.' "\n") + self.stdout.write('Use "exit" to leave the shell.\n') line = "" else: line = "EOF" diff --git a/xonsh/tools.py b/xonsh/tools.py index 9d496f7f7..a1c42659a 100644 --- a/xonsh/tools.py +++ b/xonsh/tools.py @@ -956,7 +956,7 @@ def print_warning(msg): # Notify about the traceback output possibility if neither of # the two options have been manually set sys.stderr.write( - "xonsh: For full traceback set: " "$XONSH_SHOW_TRACEBACK = True\n" + "xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True\n" ) # convert show_trace to bool if necessary if not is_bool(show_trace): @@ -1033,7 +1033,7 @@ def print_exception(msg=None, exc_info=None, source_msg=None): # Notify about the traceback output possibility if neither of # the two options have been manually set sys.stderr.write( - "xonsh: For full traceback set: " "$XONSH_SHOW_TRACEBACK = True\n" + "xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True\n" ) # convert show_trace to bool if necessary if not is_bool(show_trace): diff --git a/xonsh/tracer.py b/xonsh/tracer.py index 6023e1249..1361cdf0d 100644 --- a/xonsh/tracer.py +++ b/xonsh/tracer.py @@ -162,7 +162,7 @@ class TracerType: tracer = LazyObject(TracerType, globals(), "tracer") COLORLESS_LINE = "{fname}:{lineno}:{line}" -COLOR_LINE = "{{PURPLE}}{fname}{{BLUE}}:" "{{GREEN}}{lineno}{{BLUE}}:" "{{RESET}}" +COLOR_LINE = "{{PURPLE}}{fname}{{BLUE}}:{{GREEN}}{lineno}{{BLUE}}:{{RESET}}" def tracer_format_line(fname, lineno, line, color=True, lexer=None, formatter=None): diff --git a/xonsh/wizard.py b/xonsh/wizard.py index 9b05aa3f0..1daed5582 100644 --- a/xonsh/wizard.py +++ b/xonsh/wizard.py @@ -695,7 +695,7 @@ class StateVisitor(Visitor): YN = "{GREEN}yes{RESET} or {RED}no{RESET} [default: no]? " -YNB = "{GREEN}yes{RESET}, {RED}no{RESET}, or " "{YELLOW}break{RESET} [default: no]? " +YNB = "{GREEN}yes{RESET}, {RED}no{RESET}, or {YELLOW}break{RESET} [default: no]? " class PromptVisitor(StateVisitor): @@ -748,9 +748,7 @@ class PromptVisitor(StateVisitor): raise except Exception: if node.retry: - msg = ( - "{{BOLD_RED}}Invalid{{RESET}} input {0!r}, " "please retry." - ) + msg = "{{BOLD_RED}}Invalid{{RESET}} input {0!r}, please retry." print_color(msg.format(raw)) continue else: @@ -829,7 +827,9 @@ class PromptVisitor(StateVisitor): self.state = json.load(f) print_color(f"{{GREEN}}{fname!r} loaded.{{RESET}}") else: - print_color(f"{{RED}}{fname!r} could not be found, " "continuing.{{RESET}}") + print_color( + f"{{RED}}{fname!r} could not be found, continuing.{{{{RESET}}}}" + ) return fname def visit_fileinserter(self, node): diff --git a/xonsh/xonfig.py b/xonsh/xonfig.py index 22e99e85c..3dd643e4d 100644 --- a/xonsh/xonfig.py +++ b/xonsh/xonfig.py @@ -238,7 +238,7 @@ def make_fs_wiz(): path="/foreign_shells/{idx}/aliascmd", ), wiz.StoreNonEmpty( - ("extra command line arguments [list of str, " "default=[]]: "), + ("extra command line arguments [list of str, default=[]]: "), converter=ast.literal_eval, show_conversion=True, path="/foreign_shells/{idx}/extra_args", @@ -494,7 +494,7 @@ def _xonfig_format_human(data): if isinstance(val, list) and val: for i, subval in enumerate(val): s += row.format( - key=f"{key} {i+1}", wcol1=wcol1, val=subval, wcol2=wcol2 + key=f"{key} {i + 1}", wcol1=wcol1, val=subval, wcol2=wcol2 ) else: s += row.format(key=key, wcol1=wcol1, val=val, wcol2=wcol2) diff --git a/xonsh/xoreutils/which.py b/xonsh/xoreutils/which.py index fa06051c5..0ab531de5 100644 --- a/xonsh/xoreutils/which.py +++ b/xonsh/xoreutils/which.py @@ -37,14 +37,14 @@ def _which_create_parser(): "--version", action="version", version=f"{_which.__version__}", - help="Display the version of the python which module " "used by xonsh", + help="Display the version of the python which module used by xonsh", ) parser.add_argument( "-v", "--verbose", action="store_true", dest="verbose", - help="Print out how matches were located and show " "near misses on stderr", + help="Print out how matches were located and show near misses on stderr", ) parser.add_argument( "-p",