Skip to content

Commit d200598

Browse files
[pre-commit.ci] pre-commit autoupdate (#8547)
* [pre-commit.ci] pre-commit autoupdate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ran Benita <[email protected]>
1 parent 4b214a6 commit d200598

20 files changed

+30
-38
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434
- id: reorder-python-imports
3535
args: ['--application-directories=.:src', --py36-plus]
3636
- repo: https://github.com/asottile/pyupgrade
37-
rev: v2.11.0
37+
rev: v2.12.0
3838
hooks:
3939
- id: pyupgrade
4040
args: [--py36-plus]

src/_pytest/_code/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ def __str__(self) -> str:
968968
return io.getvalue().strip()
969969

970970
def __repr__(self) -> str:
971-
return "<{} instance at {:0x}>".format(self.__class__, id(self))
971+
return f"<{self.__class__} instance at {id(self):0x}>"
972972

973973
def toterminal(self, tw: TerminalWriter) -> None:
974974
raise NotImplementedError()

src/_pytest/_io/saferepr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def _try_repr_or_str(obj: object) -> str:
1212
except (KeyboardInterrupt, SystemExit):
1313
raise
1414
except BaseException:
15-
return '{}("{}")'.format(type(obj).__name__, obj)
15+
return f'{type(obj).__name__}("{obj}")'
1616

1717

1818
def _format_repr_exception(exc: BaseException, obj: object) -> str:
@@ -21,7 +21,7 @@ def _format_repr_exception(exc: BaseException, obj: object) -> str:
2121
except (KeyboardInterrupt, SystemExit):
2222
raise
2323
except BaseException as exc:
24-
exc_info = "unpresentable exception ({})".format(_try_repr_or_str(exc))
24+
exc_info = f"unpresentable exception ({_try_repr_or_str(exc)})"
2525
return "<[{} raised in repr()] {} object at 0x{:x}>".format(
2626
exc_info, type(obj).__name__, id(obj)
2727
)

src/_pytest/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,4 @@ def __get__(self, instance, owner=None):
418418
#
419419
# This also work for Enums (if you use `is` to compare) and Literals.
420420
def assert_never(value: "NoReturn") -> "NoReturn":
421-
assert False, "Unhandled value: {} ({})".format(value, type(value).__name__)
421+
assert False, f"Unhandled value: {value} ({type(value).__name__})"

src/_pytest/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ def import_plugin(self, modname: str, consider_entry_points: bool = False) -> No
721721
__import__(importspec)
722722
except ImportError as e:
723723
raise ImportError(
724-
'Error importing plugin "{}": {}'.format(modname, str(e.args[0]))
724+
f'Error importing plugin "{modname}": {e.args[0]}'
725725
).with_traceback(e.__traceback__) from e
726726

727727
except Skipped as e:

src/_pytest/fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def formatrepr(self) -> "FixtureLookupErrorRepr":
859859
error_msg = "file %s, line %s: source code not available"
860860
addline(error_msg % (fspath, lineno + 1))
861861
else:
862-
addline("file {}, line {}".format(fspath, lineno + 1))
862+
addline(f"file {fspath}, line {lineno + 1}")
863863
for i, line in enumerate(lines):
864864
line = line.rstrip()
865865
addline(" " + line)
@@ -908,7 +908,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
908908
lines = self.errorstring.split("\n")
909909
if lines:
910910
tw.line(
911-
"{} {}".format(FormattedExcinfo.fail_marker, lines[0].strip()),
911+
f"{FormattedExcinfo.fail_marker} {lines[0].strip()}",
912912
red=True,
913913
)
914914
for line in lines[1:]:
@@ -922,7 +922,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
922922

923923
def fail_fixturefunc(fixturefunc, msg: str) -> "NoReturn":
924924
fs, lineno = getfslineno(fixturefunc)
925-
location = "{}:{}".format(fs, lineno + 1)
925+
location = f"{fs}:{lineno + 1}"
926926
source = _pytest._code.Source(fixturefunc)
927927
fail(msg + ":\n\n" + str(source.indent()) + "\n" + location, pytrace=False)
928928

src/_pytest/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def wrap_session(
294294
except exit.Exception as exc:
295295
if exc.returncode is not None:
296296
session.exitstatus = exc.returncode
297-
sys.stderr.write("{}: {}\n".format(type(exc).__name__, exc))
297+
sys.stderr.write(f"{type(exc).__name__}: {exc}\n")
298298
else:
299299
if isinstance(excinfo.value, SystemExit):
300300
sys.stderr.write("mainloop: caught unexpected SystemExit!\n")
@@ -311,7 +311,7 @@ def wrap_session(
311311
except exit.Exception as exc:
312312
if exc.returncode is not None:
313313
session.exitstatus = exc.returncode
314-
sys.stderr.write("{}: {}\n".format(type(exc).__name__, exc))
314+
sys.stderr.write(f"{type(exc).__name__}: {exc}\n")
315315
config._ensure_unconfigure()
316316
return session.exitstatus
317317

@@ -718,7 +718,7 @@ def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
718718
# If it's a directory argument, recurse and look for any Subpackages.
719719
# Let the Package collector deal with subnodes, don't collect here.
720720
if argpath.is_dir():
721-
assert not names, "invalid arg {!r}".format((argpath, names))
721+
assert not names, f"invalid arg {(argpath, names)!r}"
722722

723723
seen_dirs: Set[Path] = set()
724724
for direntry in visit(str(argpath), self._recurse):

src/_pytest/mark/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def lex(self, input: str) -> Iterator[Token]:
103103
else:
104104
raise ParseError(
105105
pos + 1,
106-
'unexpected character "{}"'.format(input[pos]),
106+
f'unexpected character "{input[pos]}"',
107107
)
108108
yield Token(TokenType.EOF, "", pos)
109109

src/_pytest/mark/structures.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ def param(
9999

100100
if id is not None:
101101
if not isinstance(id, str):
102-
raise TypeError(
103-
"Expected id to be a string, got {}: {!r}".format(type(id), id)
104-
)
102+
raise TypeError(f"Expected id to be a string, got {type(id)}: {id!r}")
105103
id = ascii_escaped(id)
106104
return cls(values, marks, id)
107105

src/_pytest/pastebin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def create_new_paste(contents: Union[str, bytes]) -> str:
8686
return "bad response: %s" % exc_info
8787
m = re.search(r'href="/raw/(\w+)"', response)
8888
if m:
89-
return "{}/show/{}".format(url, m.group(1))
89+
return f"{url}/show/{m.group(1)}"
9090
else:
9191
return "bad response: invalid format ('" + response + "')"
9292

0 commit comments

Comments
 (0)