Skip to content

Commit 9fc42b1

Browse files
Drop the :d in f-string formatting
1 parent 923ef32 commit 9fc42b1

File tree

17 files changed

+37
-37
lines changed

17 files changed

+37
-37
lines changed

bench/empty.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
for i in range(1000):
5-
exec(f"def test_func_{i:d}(): pass")
5+
exec(f"def test_func_{i}(): pass")

src/_pytest/_code/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def relline(self) -> int:
217217
return self.lineno - self.frame.code.firstlineno
218218

219219
def __repr__(self) -> str:
220-
return f"<TracebackEntry {self.frame.code.path}:{self.lineno+1:d}>"
220+
return f"<TracebackEntry {self.frame.code.path}:{self.lineno+1}>"
221221

222222
@property
223223
def statement(self) -> Source:

src/_pytest/_io/pprint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def _pprint_deque(
540540
) -> None:
541541
stream.write(object.__class__.__name__ + "(")
542542
if object.maxlen is not None:
543-
stream.write(f"maxlen={object.maxlen:d}, ")
543+
stream.write(f"maxlen={object.maxlen}, ")
544544
stream.write("[")
545545

546546
self._format_items(object, stream, indent, allowance + 1, context, level)

src/_pytest/_py/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _geterrnoclass(self, eno: int) -> type[Error]:
6969
try:
7070
return self._errno2class[eno]
7171
except KeyError:
72-
clsname = errno.errorcode.get(eno, f"UnknownErrno{eno:d}")
72+
clsname = errno.errorcode.get(eno, f"UnknownErrno{eno}")
7373
errorcls = type(
7474
clsname,
7575
(Error,),

src/_pytest/assertion/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def _compare_eq_sequence(
406406
]
407407
else:
408408
explanation += [
409-
f"{dir_with_more} contains {len_diff:d} more items, first extra item: {highlighter(extra)}"
409+
f"{dir_with_more} contains {len_diff} more items, first extra item: {highlighter(extra)}"
410410
]
411411
return explanation
412412

@@ -509,7 +509,7 @@ def _compare_eq_dict(
509509
len_extra_left = len(extra_left)
510510
if len_extra_left:
511511
explanation.append(
512-
f"Left contains {len_extra_left:d} more item{'' if len_extra_left == 1 else 's'}:"
512+
f"Left contains {len_extra_left} more item{'' if len_extra_left == 1 else 's'}:"
513513
)
514514
explanation.extend(
515515
highlighter(pprint.pformat({k: left[k] for k in extra_left})).splitlines()
@@ -518,7 +518,7 @@ def _compare_eq_dict(
518518
len_extra_right = len(extra_right)
519519
if len_extra_right:
520520
explanation.append(
521-
f"Right contains {len_extra_right:d} more item{'' if len_extra_right == 1 else 's'}:"
521+
f"Right contains {len_extra_right} more item{'' if len_extra_right == 1 else 's'}:"
522522
)
523523
explanation.extend(
524524
highlighter(pprint.pformat({k: right[k] for k in extra_right})).splitlines()

src/_pytest/cacheprovider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def pytest_collection_modifyitems(
389389
# Running a subset of all tests with recorded failures
390390
# only outside of it.
391391
self._report_status = (
392-
f"{len(self.lastfailed):d} known failures not in selected tests"
392+
f"{len(self.lastfailed)} known failures not in selected tests"
393393
)
394394
else:
395395
if self.config.getoption("lf"):
@@ -622,5 +622,5 @@ def cacheshow(config: Config, session: Session) -> int:
622622
# print("%s/" % p.relative_to(basedir))
623623
if p.is_file():
624624
key = str(p.relative_to(basedir))
625-
tw.line(f"{key} is a file of length {p.stat().st_size:d}")
625+
tw.line(f"{key} is a file of length {p.stat().st_size}")
626626
return 0

src/_pytest/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def getlocation(function, curdir: str | os.PathLike[str] | None = None) -> str:
7171
except ValueError:
7272
pass
7373
else:
74-
return f"{relfn}:{lineno+1:d}"
75-
return f"{fn}:{lineno+1:d}"
74+
return f"{relfn}:{lineno+1}"
75+
return f"{fn}:{lineno+1}"
7676

7777

7878
def num_mock_patch_args(function) -> int:

src/_pytest/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
884884
red=True,
885885
)
886886
tw.line()
887-
tw.line(f"{os.fspath(self.filename)}:{self.firstlineno + 1:d}")
887+
tw.line(f"{os.fspath(self.filename)}:{self.firstlineno + 1}")
888888

889889

890890
def call_fixture_func(

src/_pytest/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def pytest_collection(session: Session) -> None:
349349
def pytest_runtestloop(session: Session) -> bool:
350350
if session.testsfailed and not session.config.option.continue_on_collection_errors:
351351
raise session.Interrupted(
352-
f"{session.testsfailed:d} error{'s' if session.testsfailed != 1 else ''} during collection"
352+
f"{session.testsfailed} error{'s' if session.testsfailed != 1 else ''} during collection"
353353
)
354354

355355
if session.config.option.collectonly:
@@ -587,8 +587,8 @@ def __repr__(self) -> str:
587587
return (
588588
f"<{self.__class__.__name__} {self.name} "
589589
f"exitstatus=%r "
590-
f"testsfailed={self.testsfailed:d} "
591-
f"testscollected={self.testscollected:d}>"
590+
f"testsfailed={self.testsfailed} "
591+
f"testscollected={self.testscollected}>"
592592
) % getattr(self, "exitstatus", "<UNSET>")
593593

594594
@property
@@ -652,7 +652,7 @@ def pytest_runtest_logreport(self, report: TestReport | CollectReport) -> None:
652652
self.testsfailed += 1
653653
maxfail = self.config.getvalue("maxfail")
654654
if maxfail and self.testsfailed >= maxfail:
655-
self.shouldfail = f"stopping after {self.testsfailed:d} failures"
655+
self.shouldfail = f"stopping after {self.testsfailed} failures"
656656

657657
pytest_collectreport = pytest_runtest_logreport
658658

src/_pytest/mark/structures.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def get_empty_parameterset_mark(
4848
from ..nodes import Collector
4949

5050
fs, lineno = getfslineno(func)
51-
reason = f"got empty parameter set {argnames}, function {func.__name__} at {fs}:{lineno:d}"
51+
reason = (
52+
f"got empty parameter set {argnames}, function {func.__name__} at {fs}:{lineno}"
53+
)
5254
requested_mark = config.getini(EMPTY_PARAMETERSET_OPTION)
5355
if requested_mark in ("", None, "skip"):
5456
mark = MARK_GEN.skip(reason=reason)
@@ -58,7 +60,7 @@ def get_empty_parameterset_mark(
5860
f_name = func.__name__
5961
_, lineno = getfslineno(func)
6062
raise Collector.CollectError(
61-
f"Empty parameter set in '{f_name}' at line {lineno + 1:d}"
63+
f"Empty parameter set in '{f_name}' at line {lineno + 1}"
6264
)
6365
else:
6466
raise LookupError(requested_mark)

0 commit comments

Comments
 (0)