Skip to content

Commit 1e897a4

Browse files
committed
Prefer f-strings instead of str.format
1 parent ebbdca9 commit 1e897a4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

piptools/resolver.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ def resolve(self, max_rounds: int = 10) -> set[InstallRequirement]:
266266
raise RuntimeError(
267267
"No stable configuration of concrete packages "
268268
"could be found for the given constraints after "
269-
"{max_rounds} rounds of resolving.\n"
270-
"This is likely a bug.".format(max_rounds=max_rounds)
269+
f"{max_rounds} rounds of resolving.\n"
270+
"This is likely a bug."
271271
)
272272

273273
log.debug("")
@@ -429,9 +429,9 @@ def get_best_match(self, ireq: InstallRequirement) -> InstallRequirement:
429429

430430
# Format the best match
431431
log.debug(
432-
"found candidate {} (constraint was {})".format(
433-
format_requirement(best_match), format_specifier(ireq)
434-
)
432+
"found candidate %s (constraint was %s)",
433+
format_requirement(best_match),
434+
format_specifier(ireq),
435435
)
436436
best_match.comes_from = ireq.comes_from
437437
if hasattr(ireq, "_source_ireqs"):

tests/test_cli_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,14 +1058,14 @@ def test_generate_hashes_with_editable(pip_conf, runner):
10581058
fp.write(f"-e {small_fake_package_url}\n")
10591059
out = runner.invoke(cli, ["--no-annotate", "--generate-hashes"])
10601060
expected = (
1061-
"-e {}\n"
1061+
f"-e {small_fake_package_url}\n"
10621062
"small-fake-a==0.1 \\\n"
10631063
" --hash=sha256:5e6071ee6e4c59e0d0408d366f"
10641064
"e9b66781d2cf01be9a6e19a2433bb3c5336330\n"
10651065
"small-fake-b==0.1 \\\n"
10661066
" --hash=sha256:acdba8f8b8a816213c30d5310c"
10671067
"3fe296c0107b16ed452062f7f994a5672e3b3f\n"
1068-
).format(small_fake_package_url)
1068+
)
10691069
assert out.exit_code == 0
10701070
assert expected in out.stderr
10711071

tests/test_cli_sync.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def test_pip_install_flags(run, cli_flags, expected_install_flags, runner):
205205

206206
call_args = [call[0][0] for call in run.call_args_list]
207207
called_install_options = [args[6:] for args in call_args if args[3] == "install"]
208-
assert called_install_options == [expected_install_flags], "Called args: {}".format(
209-
call_args
210-
)
208+
assert called_install_options == [
209+
expected_install_flags
210+
], f"Called args: {call_args}"
211211

212212

213213
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)