Skip to content

Commit 5ce3ec4

Browse files
smoparthclaude
andcommitted
refactor: use PEP 695 type keyword for type aliases
Replace typing.TypeAlias annotations with the Python 3.12 type statement (PEP 695) in build commands and resolver modules. This was flagged by ruff UP040 after bumping target-version to py312. Co-Authored-By: Claude <claude@anthropic.com> Signed-off-by: Shanmukh Pawan <smoparth@redhat.com>
1 parent 7819ad7 commit 5ce3ec4

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

src/fromager/commands/build.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ def dict_factory(x: list[tuple[str, typing.Any]]) -> dict[str, typing.Any]:
5858
}
5959

6060

61-
BuildSequenceEntryFuture: typing.TypeAlias = concurrent.futures.Future[
62-
BuildSequenceEntry
63-
]
64-
DependencyNodeSet: typing.TypeAlias = set[dependency_graph.DependencyNode]
61+
type BuildSequenceEntryFuture = concurrent.futures.Future[BuildSequenceEntry]
62+
type DependencyNodeSet = set[dependency_graph.DependencyNode]
6563

6664

6765
@click.command()

src/fromager/resolver.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,12 @@ def get_project_from_pypi(
369369
logger.info("ignored all candidate files at %s", sdist_server_url)
370370

371371

372-
RequirementsMap: typing.TypeAlias = typing.Mapping[str, typing.Iterable[Requirement]]
373-
Candidates: typing.TypeAlias = typing.Iterable[Candidate]
374-
CandidatesMap: typing.TypeAlias = typing.Mapping[str, Candidates]
372+
type RequirementsMap = typing.Mapping[str, typing.Iterable[Requirement]]
373+
type Candidates = typing.Iterable[Candidate]
374+
type CandidatesMap = typing.Mapping[str, Candidates]
375375
# {identifier: [cls, cachekey]: list[candidates]}}
376-
ResolverCache: typing.TypeAlias = dict[
377-
str, dict[tuple[type[ExtrasProvider], str], list[Candidate]]
378-
]
379-
VersionSource: typing.TypeAlias = typing.Callable[
376+
type ResolverCache = dict[str, dict[tuple[type[ExtrasProvider], str], list[Candidate]]]
377+
type VersionSource = typing.Callable[
380378
[str],
381379
typing.Iterable[Candidate | tuple[str, str | Version]],
382380
]

0 commit comments

Comments
 (0)