1414
1515"""Utility class to inspect an extracted wheel directory"""
1616
17- from __future__ import annotations
18-
1917import email
2018from collections import defaultdict
2119from dataclasses import dataclass , field
2220from enum import Enum , unique
21+ from pathlib import Path
22+ from typing import Dict , List , Optional , Set , Tuple
2323
2424import installer
2525import pkg_resources
@@ -33,7 +33,7 @@ class OS(Enum):
3333 windows = 3
3434
3535 @staticmethod
36- def from_tag (tag : str ) -> OS :
36+ def from_tag (tag : str ) -> "OS" :
3737 if tag .startswith ("linux" ):
3838 return OS .linux
3939 elif tag .startswith ("manylinux" ):
@@ -89,7 +89,7 @@ def __str__(self) -> str:
8989 return self .os .name .lower () + "_" + self .arch .name .lower ()
9090
9191 @classmethod
92- def from_tag (cls , tag : str ) -> Platform :
92+ def from_tag (cls , tag : str ) -> " Platform" :
9393 return cls (
9494 os = OS .from_tag (tag ),
9595 arch = Arch .from_tag (tag ),
@@ -161,18 +161,18 @@ def _default_select():
161161
162162@dataclass
163163class Deps :
164- deps : set [str ] = field (default_factory = set )
165- select : dict [Platform , set [str ]] = field (default_factory = _default_select )
164+ deps : Set [str ] = field (default_factory = set )
165+ select : Dict [Platform , Set [str ]] = field (default_factory = _default_select )
166166
167- def add (self , dep : str , platform : Platform | None = None ):
167+ def add (self , dep : str , platform : Optional [ Platform ] = None ):
168168 if platform :
169169 self .select [platform ].add (dep )
170170 else :
171171 self .deps .add (dep )
172172 for p , deps in self .select .items ():
173173 self .select [p ] = deps - {dep }
174174
175- def build (self , all_platforms : list [Platform ]) -> Deps :
175+ def build (self , all_platforms : List [Platform ]) -> " Deps" :
176176 # Move deps to common deps if they are present for all platforms
177177 common_deps = None
178178 for plat in all_platforms :
@@ -192,7 +192,7 @@ def build(self, all_platforms: list[Platform]) -> Deps:
192192class Wheel :
193193 """Representation of the compressed .whl file"""
194194
195- def __init__ (self , path : str ):
195+ def __init__ (self , path : Path ):
196196 self ._path = path
197197
198198 @property
@@ -217,13 +217,13 @@ def version(self) -> str:
217217 # TODO Also available as installer.sources.WheelSource.version
218218 return str (self .metadata ["Version" ])
219219
220- def entry_points (self ) -> dict [str , tuple [str , str ]]:
220+ def entry_points (self ) -> Dict [str , Tuple [str , str ]]:
221221 """Returns the entrypoints defined in the current wheel
222222
223223 See https://packaging.python.org/specifications/entry-points/ for more info
224224
225225 Returns:
226- dict [str, tuple [str, str]]: A mapping of the entry point's name to it's module and attribute
226+ Dict [str, Tuple [str, str]]: A mapping of the entry point's name to it's module and attribute
227227 """
228228 with installer .sources .WheelFile .open (self .path ) as wheel_source :
229229 if "entry_points.txt" not in wheel_source .dist_info_filenames :
@@ -239,7 +239,7 @@ def entry_points(self) -> dict[str, tuple[str, str]]:
239239 return entry_points_mapping
240240
241241 def dependencies (
242- self , extras_requested : set [str ] = None , platforms = list [Platform ]
242+ self , extras_requested : Set [str ] = None , platforms = List [Platform ]
243243 ) -> Deps :
244244 # NOTE @aignas 2023-12-04: if the wheel is a platform specific wheel, we only include deps for that platform
245245 _ , _ , platform_tag = self ._path .name .rpartition ("-" )
0 commit comments