[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] 2023-09-18 05:25:53 +00:00 committed by Noorhteen Raja NJ
parent b4d196db17
commit 3c78f77eea
12 changed files with 19 additions and 29 deletions

View file

@ -38,7 +38,7 @@ def test_command_not_found(monkeypatch):
assert xexec([command]) == (
None,
"xonsh: exec: file not found: {}: {}" "\n".format(dummy_error_msg, command),
f"xonsh: exec: file not found: {dummy_error_msg}: {command}" "\n",
1,
)

View file

@ -32,9 +32,9 @@ def check_news_file(fname):
cat = l[2:].rsplit(":")[0]
if cat not in CATEGORIES:
pytest.fail(
"{}:{}: {!r} not a proper category "
"must be one of {}"
"".format(name, i + 1, cat, list(CATEGORIES)),
f"{name}:{i + 1}: {cat!r} not a proper category "
f"must be one of {list(CATEGORIES)}"
"",
pytrace=True,
)
if l.endswith("None"):

View file

@ -747,7 +747,7 @@ def xexec_fn(
except FileNotFoundError as e:
return (
None,
"xonsh: exec: file not found: {}: {}" "\n".format(e.args[1], command[0]),
f"xonsh: exec: file not found: {e.args[1]}: {command[0]}" "\n",
1,
)

View file

@ -212,13 +212,7 @@ class HistoryDiffer:
brtn = self.b["cmds"][j]["rtn"]
if artn != brtn:
s += (
"Return vals {red}{artn}{reset} & {green}{brtn}{reset} differ\n"
).format(
red=COLORS.RED,
green=COLORS.GREEN,
reset=COLORS.RESET,
artn=artn,
brtn=brtn,
f"Return vals {COLORS.RED}{artn}{COLORS.RESET} & {COLORS.GREEN}{brtn}{COLORS.RESET} differ\n"
)
return s

View file

@ -244,9 +244,9 @@ def cd(args, stdin=None):
return (
"",
(
"cd takes 0 or 1 arguments, not {}. An additional `-P` "
f"cd takes 0 or 1 arguments, not {len(args)}. An additional `-P` "
"flag can be passed in first position to follow symlinks."
"\n".format(len(args))
"\n"
),
1,
)

View file

@ -109,7 +109,7 @@ class History:
else:
raise TypeError(
"history indices must be integers "
"or slices, not {}".format(type(item))
f"or slices, not {type(item)}"
)
def __setitem__(self, *args):

View file

@ -532,7 +532,7 @@ class BaseParser:
def optfunc(self, p):
p[0] = p[1]
optfunc.__doc__ = ("{0}_opt : empty\n" " | {0}").format(rulename)
optfunc.__doc__ = (f"{rulename}_opt : empty\n" f" | {rulename}")
optfunc.__name__ = "p_" + rulename + "_opt"
setattr(self.__class__, optfunc.__name__, optfunc)
@ -544,9 +544,7 @@ class BaseParser:
def listfunc(self, p):
p[0] = p[1] if len(p) == 2 else p[1] + p[2]
listfunc.__doc__ = ("{0}_list : {0}\n" " | {0}_list {0}").format(
rulename
)
listfunc.__doc__ = (f"{rulename}_list : {rulename}\n" f" | {rulename}_list {rulename}")
listfunc.__name__ = "p_" + rulename + "_list"
setattr(self.__class__, listfunc.__name__, listfunc)

View file

@ -133,7 +133,7 @@ def get_script_subproc_command(fname, args):
@xl.lazyobject
def _REDIR_REGEX():
name = r"(o(?:ut)?|e(?:rr)?|a(?:ll)?|&?\d?)"
return re.compile("{r}(>?>|<){r}$".format(r=name))
return re.compile(f"{name}(>?>|<){name}$")
@xl.lazyobject

View file

@ -132,7 +132,7 @@ class PromptFormatter:
try:
return self.fields.pick(field)
except Exception: # noqa
print("prompt: error: on field {!r}" "".format(field), 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

@ -231,11 +231,11 @@ def timeit_alias(args, stdin=None):
# timing is 4 times faster than the slowest timing or not.
if worst > 4 * best and best > 0 and worst > 1e-5:
print(
(
"The slowest run took {:0.2f} times longer than the "
f"The slowest run took {worst / best:0.2f} times longer than the "
"fastest. This could mean that an intermediate result "
"is being cached."
).format(worst / best)
)
print(
f"{number} loops, best of {repeat}: {format_time(best, precision)} per loop"

View file

@ -2708,7 +2708,7 @@ def columnize(elems, width=80, newline="\n"):
data = [elems[i * nrows : (i + 1) * nrows] for i in range(ncols)]
colwidths = [max(map(len, d)) + pad for d in data]
colwidths[-1] -= pad
row_t = "".join(["{{row[{i}]: <{{w[{i}]}}}}".format(i=i) for i in range(ncols)])
row_t = "".join([f"{{row[{i}]: <{{w[{i}]}}}}" for i in range(ncols)])
row_t += newline
lines = [
row_t.format(row=row, w=colwidths)

View file

@ -508,7 +508,7 @@ class PrettyFormatter(Visitor):
if node.path is None:
s += "\n])"
else:
s += "{0}],\n{0}path={1!r}\n)".format(self.indent, node.path)
s += f"{self.indent}],\n{self.indent}path={node.path!r}\n)"
return s
def visit_message(self, node):
@ -830,9 +830,7 @@ class PromptVisitor(StateVisitor):
print_color(f"{{GREEN}}{fname!r} loaded.{{RESET}}")
else:
print_color(
("{{RED}}{!r} could not be found, " "continuing.{{RESET}}").format(
fname
)
f"{{RED}}{fname!r} could not be found, " "continuing.{{RESET}}"
)
return fname