Skip to content

Commit 102d818

Browse files
Enforce ruff/pyupgrade rules (UP) (#12936)
1 parent 111eed1 commit 102d818

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ select = [
181181
"PLR0",
182182
"W",
183183
"RUF100",
184-
"UP032",
184+
"UP",
185185
]
186186

187187
[tool.ruff.lint.isort]

src/pip/_internal/cli/index_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SessionCommandMixin(CommandContextMixIn):
5454

5555
def __init__(self) -> None:
5656
super().__init__()
57-
self._session: Optional["PipSession"] = None
57+
self._session: Optional[PipSession] = None
5858

5959
@classmethod
6060
def _get_index_urls(cls, options: Values) -> Optional[List[str]]:

src/pip/_internal/commands/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def run(self, options: Values, args: List[str]) -> int:
176176
if options.excludes:
177177
skip.update(canonicalize_name(n) for n in options.excludes)
178178

179-
packages: "_ProcessedDists" = [
179+
packages: _ProcessedDists = [
180180
cast("_DistWithLatestInfo", d)
181181
for d in get_environment(options.path).iter_installed_distributions(
182182
local_only=options.local,

src/pip/_internal/commands/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def transform_hits(hits: List[Dict[str, str]]) -> List["TransformedHit"]:
8989
packages with the list of versions stored inline. This converts the
9090
list from pypi into one we can use.
9191
"""
92-
packages: Dict[str, "TransformedHit"] = OrderedDict()
92+
packages: Dict[str, TransformedHit] = OrderedDict()
9393
for hit in hits:
9494
name = hit["name"]
9595
summary = hit["summary"]

src/pip/_internal/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class HashErrors(InstallationError):
429429
"""Multiple HashError instances rolled into one for reporting"""
430430

431431
def __init__(self) -> None:
432-
self.errors: List["HashError"] = []
432+
self.errors: List[HashError] = []
433433

434434
def append(self, error: "HashError") -> None:
435435
self.errors.append(error)

src/pip/_internal/req/constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _set_requirement_extras(req: Requirement, new_extras: Set[str]) -> Requireme
8080
assert (
8181
pre is not None and post is not None
8282
), f"regex group selection for requirement {req} failed, this should never happen"
83-
extras: str = "[%s]" % ",".join(sorted(new_extras)) if new_extras else ""
83+
extras: str = "[{}]".format(",".join(sorted(new_extras)) if new_extras else "")
8484
return get_requirement(f"{pre}{extras}{post}")
8585

8686

tests/functional/test_search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_pypi_xml_transformation() -> None:
4545
"version": "1.0",
4646
},
4747
]
48-
expected: List["TransformedHit"] = [
48+
expected: List[TransformedHit] = [
4949
{
5050
"versions": ["1.0", "2.0"],
5151
"name": "foo",
@@ -159,7 +159,7 @@ def test_latest_prerelease_install_message(
159159
"""
160160
Test documentation for installing pre-release packages is displayed
161161
"""
162-
hits: List["TransformedHit"] = [
162+
hits: List[TransformedHit] = [
163163
{
164164
"name": "ni",
165165
"summary": "For knights who say Ni!",
@@ -188,7 +188,7 @@ def test_search_print_results_should_contain_latest_versions(
188188
"""
189189
Test that printed search results contain the latest package versions
190190
"""
191-
hits: List["TransformedHit"] = [
191+
hits: List[TransformedHit] = [
192192
{
193193
"name": "testlib1",
194194
"summary": "Test library 1.",

tests/unit/resolution_resolvelib/test_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def build_requirement_information(
1919
install_requirement = install_req_from_req_string(name)
2020
# RequirementInformation is typed as a tuple, but it is a namedtupled.
2121
# https://github.com/sarugaku/resolvelib/blob/7bc025aa2a4e979597c438ad7b17d2e8a08a364e/src/resolvelib/resolvers.pyi#L20-L22
22-
requirement_information: "PreferenceInformation" = RequirementInformation(
22+
requirement_information: PreferenceInformation = RequirementInformation(
2323
requirement=SpecifierRequirement(install_requirement), # type: ignore[call-arg]
2424
parent=parent,
2525
)

tests/unit/resolution_resolvelib/test_resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _make_graph(
3838
) -> "DirectedGraph[Optional[str]]":
3939
"""Build graph from edge declarations."""
4040

41-
graph: "DirectedGraph[Optional[str]]" = DirectedGraph()
41+
graph: DirectedGraph[Optional[str]] = DirectedGraph()
4242
for parent, child in edges:
4343
parent = cast(str, canonicalize_name(parent)) if parent else None
4444
child = cast(str, canonicalize_name(child)) if child else None

0 commit comments

Comments
 (0)