From 622f104694e3091f194b6f01d94154f8f4c56348 Mon Sep 17 00:00:00 2001 From: Andrey Bienkowski Date: Tue, 30 Mar 2021 15:48:27 +0300 Subject: [PATCH] Use f-strings for formatting suggested by pyupgrade --py36-plus --- src/pip/_internal/resolution/resolvelib/factory.py | 2 +- src/pip/_internal/utils/compat.py | 4 +--- src/pip/_internal/utils/misc.py | 2 +- src/pip/_internal/utils/subprocess.py | 2 +- src/pip/_internal/utils/wheel.py | 2 +- tests/functional/test_install_config.py | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index aa6c4781d2e..a4eec7136bb 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -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() diff --git a/src/pip/_internal/utils/compat.py b/src/pip/_internal/utils/compat.py index 0cb1c469704..1fb2dc729e0 100644 --- a/src/pip/_internal/utils/compat.py +++ b/src/pip/_internal/utils/compat.py @@ -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 diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py index 96e26a09ca4..714a36e9c41 100644 --- a/src/pip/_internal/utils/misc.py +++ b/src/pip/_internal/utils/misc.py @@ -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}" ) diff --git a/src/pip/_internal/utils/subprocess.py b/src/pip/_internal/utils/subprocess.py index cfde1870081..2c8cf21231d 100644 --- a/src/pip/_internal/utils/subprocess.py +++ b/src/pip/_internal/utils/subprocess.py @@ -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 diff --git a/src/pip/_internal/utils/wheel.py b/src/pip/_internal/utils/wheel.py index 982508eb4f6..42f080845cf 100644 --- a/src/pip/_internal/utils/wheel.py +++ b/src/pip/_internal/utils/wheel.py @@ -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}" ) diff --git a/tests/functional/test_install_config.py b/tests/functional/test_install_config.py index ed33b0c9f83..59aec65ffe8 100644 --- a/tests/functional/test_install_config.py +++ b/tests/functional/test_install_config.py @@ -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