22import re
33import sys
44import types
5+ from collections .abc import Iterator
56from pathlib import Path
67from typing import (
78 Any ,
8- Dict ,
9- Iterator ,
10- List ,
119 NamedTuple ,
12- Optional ,
13- Tuple ,
14- Type ,
1510)
1611
1712import yaml
3328_V6_FORMAT_VERSIONS = {6 , 7 }
3429_SUPPORTED_VERSIONS = {6 , 7 , 9 }
3530
36- _STORE_VERSION_BY_LOCKFILE : Dict [int , str ] = {
31+ _STORE_VERSION_BY_LOCKFILE : dict [int , str ] = {
3732 6 : 'v3' ,
3833 7 : 'v3' ,
3934 9 : 'v10' ,
@@ -60,7 +55,7 @@ def _get_tarball_url(
6055 self ,
6156 name : str ,
6257 version : str ,
63- resolution : Dict [str , Any ],
58+ resolution : dict [str , Any ],
6459 ) -> str :
6560 if 'tarball' in resolution :
6661 return str (resolution ['tarball' ])
@@ -72,7 +67,7 @@ def _get_tarball_url(
7267
7368 return f'{ self .registry } /{ name } /-/{ basename } -{ version } .tgz'
7469
75- def _parse_package_key (self , key : str , major : int ) -> Optional [ Tuple [ str , str ]] :
70+ def _parse_package_key (self , key : str , major : int ) -> tuple [ str , str ] | None :
7671 if major in _V6_FORMAT_VERSIONS :
7772 match = self ._V6_PACKAGE_RE .match (key )
7873 else :
@@ -107,7 +102,7 @@ def process_lockfile(self, lockfile_path: Path) -> Iterator[Package]:
107102
108103 lockfile = Lockfile (lockfile_path , major )
109104
110- packages_dict : Dict [str , Any ] = data .get ('packages' , {})
105+ packages_dict : dict [str , Any ] = data .get ('packages' , {})
111106 if not packages_dict :
112107 return
113108
@@ -125,7 +120,7 @@ def process_lockfile(self, lockfile_path: Path) -> Iterator[Package]:
125120 if self .no_devel and info .get ('dev' , False ):
126121 continue
127122
128- resolution : Dict [str , Any ] = info .get ('resolution' , {})
123+ resolution : dict [str , Any ] = info .get ('resolution' , {})
129124 if not resolution :
130125 continue
131126
@@ -173,14 +168,14 @@ def __init__(
173168 self .lockfile_root = lockfile_root
174169 self .tarball_dir = self .gen .data_root / 'pnpm-tarballs'
175170 self .store_dir = self .gen .data_root / 'pnpm-store'
176- self ._tarballs : List [PnpmModuleProvider ._TarballInfo ] = []
177- self ._store_version : Optional [ str ] = None
171+ self ._tarballs : list [PnpmModuleProvider ._TarballInfo ] = []
172+ self ._store_version : str | None = None
178173
179174 def __exit__ (
180175 self ,
181- exc_type : Optional [ Type [ BaseException ]] ,
182- exc_value : Optional [ BaseException ] ,
183- tb : Optional [ types .TracebackType ] ,
176+ exc_type : type [ BaseException ] | None ,
177+ exc_value : BaseException | None ,
178+ tb : types .TracebackType | None ,
184179 ) -> None :
185180 if exc_type is None :
186181 self ._finalize ()
@@ -281,7 +276,7 @@ def __init__(
281276 def create_lockfile_provider (self ) -> PnpmLockfileProvider :
282277 return PnpmLockfileProvider (self .options .lockfile )
283278
284- def create_rcfile_providers (self ) -> List [RCFileProvider ]:
279+ def create_rcfile_providers (self ) -> list [RCFileProvider ]:
285280 return [NpmRCFileProvider ()]
286281
287282 def create_module_provider (
0 commit comments