Skip to content

Commit

Permalink
Merge pull request #9745 from hexagonrecursion/f-str
Browse files Browse the repository at this point in the history
[pyupgrade] Use f-strings for formatting
  • Loading branch information
pradyunsg authored Apr 2, 2021
2 parents 5803bb6 + 622f104 commit 58ca200
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def describe_trigger(parent):
relevant_constraints.add(req.name)
msg = msg + "\n "
if parent:
msg = msg + "{} {} depends on ".format(parent.name, parent.version)
msg = msg + f"{parent.name} {parent.version} depends on "
else:
msg = msg + "The user requested "
msg = msg + req.format_for_error()
Expand Down
4 changes: 1 addition & 3 deletions src/pip/_internal/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def get_path_uid(path):
file_uid = os.stat(path).st_uid
else:
# raise OSError for parity with os.O_NOFOLLOW above
raise OSError(
"{} is a symlink; Will not return uid for symlinks".format(path)
)
raise OSError(f"{path} is a symlink; Will not return uid for symlinks")
return file_uid


Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _check_no_input(message):
"""Raise an error if no input is allowed."""
if os.environ.get("PIP_NO_INPUT"):
raise Exception(
"No input was expected ($PIP_NO_INPUT set); question: {}".format(message)
f"No input was expected ($PIP_NO_INPUT set); question: {message}"
)


Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def call_subprocess(
elif on_returncode == "ignore":
pass
else:
raise ValueError("Invalid value: on_returncode={!r}".format(on_returncode))
raise ValueError(f"Invalid value: on_returncode={on_returncode!r}")
return output


Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_metadata(self, name):
except UnicodeDecodeError as e:
# Augment the default error with the origin of the file.
raise UnsupportedWheel(
"Error decoding metadata for {}: {}".format(self._wheel_name, e)
f"Error decoding metadata for {self._wheel_name}: {e}"
)


Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_install_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_prompt_for_keyring_if_needed(script, data, cert_factory, auth_needed):
response(str(data.packages / "simple-3.0.tar.gz")),
]

url = "https://{}:{}/simple".format(server.host, server.port)
url = f"https://{server.host}:{server.port}/simple"

keyring_content = textwrap.dedent("""\
import os
Expand Down

0 comments on commit 58ca200

Please sign in to comment.