Skip to content

Commit 38cb761

Browse files
committed
Apply auto fix of rule UP032
1 parent f5c5b85 commit 38cb761

File tree

13 files changed

+29
-57
lines changed

13 files changed

+29
-57
lines changed

src/pip/_internal/commands/search.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ def search(self, query: List[str], options: Values) -> List[Dict[str, str]]:
7575
try:
7676
hits = pypi.search({"name": query, "summary": query}, "or")
7777
except xmlrpc.client.Fault as fault:
78-
message = "XMLRPC request failed [code: {code}]\n{string}".format(
79-
code=fault.faultCode,
80-
string=fault.faultString,
81-
)
78+
message = f"XMLRPC request failed [code: {fault.faultCode}]\n{fault.faultString}"
8279
raise CommandError(message)
8380
assert isinstance(hits, list)
8481
return hits

src/pip/_internal/models/candidate.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ def __init__(self, name: str, version: str, link: Link) -> None:
2020
)
2121

2222
def __repr__(self) -> str:
23-
return "<InstallationCandidate({!r}, {!r}, {!r})>".format(
24-
self.name,
25-
self.version,
26-
self.link,
27-
)
23+
return f"<InstallationCandidate({self.name!r}, {self.version!r}, {self.link!r})>"
2824

2925
def __str__(self) -> str:
3026
return f"{self.name!r} candidate (version {self.version} at {self.link})"

src/pip/_internal/operations/build/wheel_legacy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def get_legacy_build_wheel_path(
4040
# Sort for determinism.
4141
names = sorted(names)
4242
if not names:
43-
msg = ("Legacy build of wheel for {!r} created no files.\n").format(name)
43+
msg = (f"Legacy build of wheel for {name!r} created no files.\n")
4444
msg += format_command_result(command_args, command_output)
4545
logger.warning(msg)
4646
return None
4747

4848
if len(names) > 1:
4949
msg = (
50-
"Legacy build of wheel for {!r} created more than one file.\n"
51-
"Filenames (choosing first): {}\n"
52-
).format(name, names)
50+
f"Legacy build of wheel for {name!r} created more than one file.\n"
51+
f"Filenames (choosing first): {names}\n"
52+
)
5353
msg += format_command_result(command_args, command_output)
5454
logger.warning(msg)
5555

src/pip/_internal/operations/install/wheel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,20 +505,20 @@ def make_data_scheme_file(record_path: RecordPath) -> "File":
505505
_, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
506506
except ValueError:
507507
message = (
508-
"Unexpected file in {}: {!r}. .data directory contents"
508+
f"Unexpected file in {wheel_path}: {record_path!r}. .data directory contents"
509509
" should be named like: '<scheme key>/<path>'."
510-
).format(wheel_path, record_path)
510+
)
511511
raise InstallationError(message)
512512

513513
try:
514514
scheme_path = scheme_paths[scheme_key]
515515
except KeyError:
516516
valid_scheme_keys = ", ".join(sorted(scheme_paths))
517517
message = (
518-
"Unknown scheme key used in {}: {} (for file {!r}). .data"
518+
f"Unknown scheme key used in {wheel_path}: {scheme_key} (for file {record_path!r}). .data"
519519
" directory contents should be in subdirectories named"
520-
" with a valid scheme key ({})"
521-
).format(wheel_path, scheme_key, record_path, valid_scheme_keys)
520+
f" with a valid scheme key ({valid_scheme_keys})"
521+
)
522522
raise InstallationError(message)
523523

524524
dest_path = os.path.join(scheme_path, dest_subpath)

src/pip/_internal/req/constructors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def parse_editable(editable_req: str) -> Tuple[Optional[str], str, Set[str]]:
132132
package_name = link.egg_fragment
133133
if not package_name:
134134
raise InstallationError(
135-
"Could not detect requirement name for '{}', please specify one "
136-
"with #egg=your_package_name".format(editable_req)
135+
f"Could not detect requirement name for '{editable_req}', please specify one "
136+
"with #egg=your_package_name"
137137
)
138138
return package_name, url, set()
139139

src/pip/_internal/req/req_install.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ def __str__(self) -> str:
222222
return s
223223

224224
def __repr__(self) -> str:
225-
return "<{} object: {} editable={!r}>".format(
226-
self.__class__.__name__, str(self), self.editable
227-
)
225+
return f"<{self.__class__.__name__} object: {str(self)} editable={self.editable!r}>"
228226

229227
def format_debug(self) -> str:
230228
"""An un-tested helper for getting state, for debugging."""

src/pip/_internal/req/req_uninstall.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,9 @@ def from_dist(cls, dist: BaseDistribution) -> "UninstallPathSet":
510510

511511
elif dist.installed_by_distutils:
512512
raise UninstallationError(
513-
"Cannot uninstall {!r}. It is a distutils installed project "
513+
f"Cannot uninstall {dist.raw_name!r}. It is a distutils installed project "
514514
"and thus we cannot accurately determine which files belong "
515-
"to it which would lead to only a partial uninstall.".format(
516-
dist.raw_name,
517-
)
515+
"to it which would lead to only a partial uninstall."
518516
)
519517

520518
elif dist.installed_as_egg:

src/pip/_internal/resolution/legacy/resolver.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ def _check_dist_requires_python(
104104
return
105105

106106
raise UnsupportedPythonVersion(
107-
"Package {!r} requires a different Python: {} not in {!r}".format(
108-
dist.raw_name, version, requires_python
109-
)
107+
f"Package {dist.raw_name!r} requires a different Python: {version} not in {requires_python!r}"
110108
)
111109

112110

@@ -263,9 +261,7 @@ def _add_requirement_to_set(
263261
)
264262
if has_conflicting_requirement:
265263
raise InstallationError(
266-
"Double requirement given: {} (already in {}, name={!r})".format(
267-
install_req, existing_req, install_req.name
268-
)
264+
f"Double requirement given: {install_req} (already in {existing_req}, name={install_req.name!r})"
269265
)
270266

271267
# When no existing requirement exists, add the requirement as a

src/pip/_internal/resolution/resolvelib/candidates.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,7 @@ def version(self) -> CandidateVersion:
191191
return self._version
192192

193193
def format_for_error(self) -> str:
194-
return "{} {} (from {})".format(
195-
self.name,
196-
self.version,
197-
self._link.file_path if self._link.is_file else self._link,
198-
)
194+
return f"{self.name} {self.version} (from {self._link.file_path if self._link.is_file else self._link})"
199195

200196
def _prepare_distribution(self) -> BaseDistribution:
201197
raise NotImplementedError("Override in subclass")
@@ -269,9 +265,7 @@ def __init__(
269265
# Version may not be present for PEP 508 direct URLs
270266
if version is not None:
271267
wheel_version = Version(wheel.version)
272-
assert version == wheel_version, "{!r} != {!r} for wheel {}".format(
273-
version, wheel_version, name
274-
)
268+
assert version == wheel_version, f"{version!r} != {wheel_version!r} for wheel {name}"
275269

276270
if cache_entry is not None:
277271
assert ireq.link.is_wheel

src/pip/_internal/utils/direct_url_helpers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def direct_url_as_pep440_direct_reference(direct_url: DirectUrl, name: str) -> s
1212
requirement = name + " @ "
1313
fragments = []
1414
if isinstance(direct_url.info, VcsInfo):
15-
requirement += "{}+{}@{}".format(
16-
direct_url.info.vcs, direct_url.url, direct_url.info.commit_id
17-
)
15+
requirement += f"{direct_url.info.vcs}+{direct_url.url}@{direct_url.info.commit_id}"
1816
elif isinstance(direct_url.info, ArchiveInfo):
1917
requirement += direct_url.url
2018
if direct_url.info.hash:

0 commit comments

Comments
 (0)