Skip to content

Commit 551e822

Browse files
authored
Merge pull request #12595 from notatallshaw/update-ruff-to-v0.3.4
Update ruff to v0.3.6
2 parents 550388e + f633c5d commit 551e822

File tree

17 files changed

+52
-62
lines changed

17 files changed

+52
-62
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repos:
2222
- id: black
2323

2424
- repo: https://github.com/astral-sh/ruff-pre-commit
25-
rev: v0.2.0
25+
rev: v0.3.6
2626
hooks:
2727
- id: ruff
2828
args: [--fix, --exit-non-zero-on-fix]

news/12595.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update ruff pre-commit to v0.3.6

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ max-complexity = 33 # default is 10
201201
"src/pip/_internal/*" = ["PERF203"]
202202
"tests/*" = ["B011"]
203203
"tests/unit/test_finder.py" = ["C414"]
204+
"src/pip/__pip-runner__.py" = ["UP"] # Must be compatible with Python 2.7
204205

205206
[tool.ruff.lint.pylint]
206207
max-args = 15 # default is 5

src/pip/_internal/commands/search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ 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,
78+
message = (
79+
f"XMLRPC request failed [code: {fault.faultCode}]\n{fault.faultString}"
8180
)
8281
raise CommandError(message)
8382
assert isinstance(hits, list)

src/pip/_internal/models/candidate.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ 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,
23+
return (
24+
f"<InstallationCandidate({self.name!r}, {self.version!r}, {self.link!r})>"
2725
)
2826

2927
def __str__(self) -> str:

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import logging
44
import os
55
from types import TracebackType
6-
from typing import Dict, Generator, Optional, Set, Type, Union
6+
from typing import Dict, Generator, Optional, Type, Union
77

8-
from pip._internal.models.link import Link
98
from pip._internal.req.req_install import InstallRequirement
109
from pip._internal.utils.temp_dir import TempDirectory
1110

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: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,20 +505,21 @@ 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"
509-
" should be named like: '<scheme key>/<path>'."
510-
).format(wheel_path, record_path)
508+
f"Unexpected file in {wheel_path}: {record_path!r}. .data directory"
509+
" contents should be named like: '<scheme key>/<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"
519-
" directory contents should be in subdirectories named"
520-
" with a valid scheme key ({})"
521-
).format(wheel_path, scheme_key, record_path, valid_scheme_keys)
518+
f"Unknown scheme key used in {wheel_path}: {scheme_key} "
519+
f"(for file {record_path!r}). .data directory contents "
520+
f"should be in subdirectories named with a valid scheme "
521+
f"key ({valid_scheme_keys})"
522+
)
522523
raise InstallationError(message)
523524

524525
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}', "
136+
"please specify one with #egg=your_package_name"
137137
)
138138
return package_name, url, set()
139139

src/pip/_internal/req/req_install.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ 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
225+
return (
226+
f"<{self.__class__.__name__} object: "
227+
f"{str(self)} editable={self.editable!r}>"
227228
)
228229

229230
def format_debug(self) -> str:

0 commit comments

Comments
 (0)