[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-03-03 17:35:38 +00:00
parent 72fa154f8f
commit e68dc16c2c
39 changed files with 132 additions and 184 deletions

View file

@ -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,
)

View file

@ -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)

View file

@ -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,
)
)

View file

@ -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),

View file

@ -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"

View file

@ -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(

View file

@ -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)

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -373,7 +373,7 @@ def convert_macro_arg(raw_arg, kind, glbs, locs, *, name="<arg>", macroname="<ma
elif kind is type:
arg = type(execer.eval(raw_arg, glbs=glbs, locs=locs, filename=filename))
else:
msg = "kind={0!r} and mode={1!r} was not recognized for macro " "argument {2!r}"
msg = "kind={0!r} and mode={1!r} was not recognized for macro argument {2!r}"
raise TypeError(msg.format(kind, mode, name))
return arg

View file

@ -94,12 +94,7 @@ def RE_XONSH_COLOR():
r"INTENSE_RED|INTENSE_GREEN|INTENSE_YELLOW|INTENSE_BLUE|INTENSE_PURPLE|"
r"INTENSE_CYAN|INTENSE_WHITE|#" + hex + "{3}|#" + hex + "{6}|DEFAULT)"
)
bghex = (
"bg#" + hex + "{3}|"
"bg#" + hex + "{6}|"
"BG#" + hex + "{3}|"
"BG#" + hex + "{6}"
)
bghex = "bg#" + hex + "{3}|bg#" + hex + "{6}|BG#" + hex + "{3}|BG#" + hex + "{6}"
s = "^((?P<reset>RESET|NO_COLOR)|(?P<bghex>" + bghex + ")|" + s + ")$"
return re.compile(s)

View file

@ -89,9 +89,9 @@ def _bash_completion_paths_default():
gfwp = _git_for_windows_path()
if gfwp:
bcd = (
os.path.join(gfwp, "usr\\share\\bash-completion\\" "bash_completion"),
os.path.join(gfwp, "usr\\share\\bash-completion\\bash_completion"),
os.path.join(
gfwp, "mingw64\\share\\git\\completion\\" "git-completion.bash"
gfwp, "mingw64\\share\\git\\completion\\git-completion.bash"
),
)
else:

View file

@ -1870,7 +1870,7 @@ This is to reduce the noise in generated completions.""",
)
CASE_SENSITIVE_COMPLETIONS = Var.with_default(
ON_LINUX,
"Sets whether completions should be case sensitive or case " "insensitive.",
"Sets whether completions should be case sensitive or case insensitive.",
doc_default="True on Linux, False otherwise.",
)
COMPLETIONS_BRACKETS = Var.with_default(

View file

@ -212,7 +212,7 @@ class Execer:
):
"""print some debugging info if asked for."""
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, last_error_line, last_error_col, mstr, line, sbpline

View file

@ -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=()):

View file

@ -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.

View file

@ -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),

View file

@ -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

View file

@ -668,7 +668,7 @@ class Inspector:
if fname.endswith((".so", ".dll", ".pyd")):
binary_file = True
elif fname.endswith("<string>"):
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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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):

View file

@ -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):

View file

@ -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):

View file

@ -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)

View file

@ -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",