1
1
"""Build Environment used for isolation during sdist building"""
2
2
3
+ from __future__ import annotations
4
+
3
5
import logging
4
6
import os
5
7
import pathlib
9
11
from collections import OrderedDict
10
12
from collections .abc import Iterable
11
13
from types import TracebackType
12
- from typing import TYPE_CHECKING , Optional , Union
14
+ from typing import TYPE_CHECKING
13
15
14
16
from pip ._vendor .packaging .version import Version
15
17
28
30
logger = logging .getLogger (__name__ )
29
31
30
32
31
- def _dedup (a : str , b : str ) -> Union [ tuple [str ], tuple [str , str ] ]:
33
+ def _dedup (a : str , b : str ) -> tuple [str ] | tuple [str , str ]:
32
34
return (a , b ) if a != b else (a ,)
33
35
34
36
@@ -157,9 +159,9 @@ def __enter__(self) -> None:
157
159
158
160
def __exit__ (
159
161
self ,
160
- exc_type : Optional [ type [BaseException ]] ,
161
- exc_val : Optional [ BaseException ] ,
162
- exc_tb : Optional [ TracebackType ] ,
162
+ exc_type : type [BaseException ] | None ,
163
+ exc_val : BaseException | None ,
164
+ exc_tb : TracebackType | None ,
163
165
) -> None :
164
166
for varname , old_value in self ._save_env .items ():
165
167
if old_value is None :
@@ -203,7 +205,7 @@ def check_requirements(
203
205
204
206
def install_requirements (
205
207
self ,
206
- finder : " PackageFinder" ,
208
+ finder : PackageFinder ,
207
209
requirements : Iterable [str ],
208
210
prefix_as_string : str ,
209
211
* ,
@@ -225,7 +227,7 @@ def install_requirements(
225
227
@staticmethod
226
228
def _install_requirements (
227
229
pip_runnable : str ,
228
- finder : " PackageFinder" ,
230
+ finder : PackageFinder ,
229
231
requirements : Iterable [str ],
230
232
prefix : _Prefix ,
231
233
* ,
@@ -306,9 +308,9 @@ def __enter__(self) -> None:
306
308
307
309
def __exit__ (
308
310
self ,
309
- exc_type : Optional [ type [BaseException ]] ,
310
- exc_val : Optional [ BaseException ] ,
311
- exc_tb : Optional [ TracebackType ] ,
311
+ exc_type : type [BaseException ] | None ,
312
+ exc_val : BaseException | None ,
313
+ exc_tb : TracebackType | None ,
312
314
) -> None :
313
315
pass
314
316
@@ -317,7 +319,7 @@ def cleanup(self) -> None:
317
319
318
320
def install_requirements (
319
321
self ,
320
- finder : " PackageFinder" ,
322
+ finder : PackageFinder ,
321
323
requirements : Iterable [str ],
322
324
prefix_as_string : str ,
323
325
* ,
0 commit comments