Skip to content

Commit

Permalink
Use real type instead of typing alias for annotations
Browse files Browse the repository at this point in the history
These have been deprecated since Python 3.9, but are usable on 3.8 with
when using `from __future__ import annotations`, as these annotations
are not evaluated at runtime.
  • Loading branch information
WhyNotHugo committed Feb 18, 2025
1 parent ebbdca9 commit a6fb8c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from abc import ABCMeta, abstractmethod
from functools import partial
from itertools import chain, count, groupby
from typing import Any, Container, DefaultDict, Iterable, Iterator
from typing import Any, Container, Iterable, Iterator

import click
from pip._internal.exceptions import DistributionNotFound
Expand Down Expand Up @@ -532,7 +532,7 @@ def __init__(
self.existing_constraints = existing_constraints

# Categorize InstallRequirements into sets by key
constraints_sets: DefaultDict[str, set[InstallRequirement]] = (
constraints_sets: collections.defaultdict[str, set[InstallRequirement]] = (
collections.defaultdict(set)
)
for ireq in constraints:
Expand Down Expand Up @@ -746,7 +746,9 @@ def _get_install_requirements(
def _get_reverse_dependencies(
resolver_result: Result,
) -> dict[str, set[str]]:
reverse_dependencies: DefaultDict[str, set[str]] = collections.defaultdict(set)
reverse_dependencies: collections.defaultdict[str, set[str]] = (
collections.defaultdict(set)
)

for candidate in resolver_result.mapping.values():
stripped_name = strip_extras(canonicalize_name(candidate.name))
Expand Down
4 changes: 2 additions & 2 deletions piptools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import tempfile
from subprocess import run # nosec
from typing import Deque, Iterable, Mapping, ValuesView
from typing import Iterable, Mapping, ValuesView

import click
from pip._internal.models.direct_url import ArchiveInfo
Expand Down Expand Up @@ -54,7 +54,7 @@ def dependency_tree(
:type root_key: str
"""
dependencies = set()
queue: Deque[Distribution] = collections.deque()
queue: collections.deque[Distribution] = collections.deque()

if root_key in installed_keys:
dep = installed_keys[root_key]
Expand Down

0 comments on commit a6fb8c8

Please sign in to comment.