23
23
from itertools import chain , starmap
24
24
from pathlib import Path
25
25
from tempfile import TemporaryDirectory
26
+ from types import TracebackType
26
27
from typing import TYPE_CHECKING , Iterable , Iterator , Mapping , Protocol , TypeVar , cast
27
28
28
29
from .. import Command , _normalization , _path , errors , namespaces
@@ -383,7 +384,13 @@ def __call__(self, wheel: WheelFile, files: list[str], mapping: dict[str, str]):
383
384
384
385
def __enter__ (self ) -> Self : ...
385
386
386
- def __exit__ (self , _exc_type , _exc_value , _traceback ): ...
387
+ def __exit__ (
388
+ self ,
389
+ exc_type : type [BaseException ] | None ,
390
+ exc_value : BaseException | None ,
391
+ traceback : TracebackType | None ,
392
+ / ,
393
+ ) -> object : ...
387
394
388
395
389
396
class _StaticPth :
@@ -397,15 +404,21 @@ def __call__(self, wheel: WheelFile, files: list[str], mapping: dict[str, str]):
397
404
contents = _encode_pth (f"{ entries } \n " )
398
405
wheel .writestr (f"__editable__.{ self .name } .pth" , contents )
399
406
400
- def __enter__ (self ):
407
+ def __enter__ (self ) -> Self :
401
408
msg = f"""
402
409
Editable install will be performed using .pth file to extend `sys.path` with:
403
410
{ list (map (os .fspath , self .path_entries ))!r}
404
411
"""
405
412
_logger .warning (msg + _LENIENT_WARNING )
406
413
return self
407
414
408
- def __exit__ (self , _exc_type , _exc_value , _traceback ): ...
415
+ def __exit__ (
416
+ self ,
417
+ _exc_type : object ,
418
+ _exc_value : object ,
419
+ _traceback : object ,
420
+ ) -> None :
421
+ pass
409
422
410
423
411
424
class _LinkTree (_StaticPth ):
@@ -463,12 +476,17 @@ def _create_links(self, outputs, output_mapping):
463
476
for relative , src in mappings .items ():
464
477
self ._create_file (relative , src , link = link_type )
465
478
466
- def __enter__ (self ):
479
+ def __enter__ (self ) -> Self :
467
480
msg = "Strict editable install will be performed using a link tree.\n "
468
481
_logger .warning (msg + _STRICT_WARNING )
469
482
return self
470
483
471
- def __exit__ (self , _exc_type , _exc_value , _traceback ):
484
+ def __exit__ (
485
+ self ,
486
+ _exc_type : object ,
487
+ _exc_value : object ,
488
+ _traceback : object ,
489
+ ) -> None :
472
490
msg = f"""\n
473
491
Strict editable installation performed using the auxiliary directory:
474
492
{ self .auxiliary_dir }
@@ -524,12 +542,17 @@ def __call__(self, wheel: WheelFile, files: list[str], mapping: dict[str, str]):
524
542
for file , content in self .get_implementation ():
525
543
wheel .writestr (file , content )
526
544
527
- def __enter__ (self ):
545
+ def __enter__ (self ) -> Self :
528
546
msg = "Editable install will be performed using a meta path finder.\n "
529
547
_logger .warning (msg + _LENIENT_WARNING )
530
548
return self
531
549
532
- def __exit__ (self , _exc_type , _exc_value , _traceback ):
550
+ def __exit__ (
551
+ self ,
552
+ _exc_type : object ,
553
+ _exc_value : object ,
554
+ _traceback : object ,
555
+ ) -> None :
533
556
msg = """\n
534
557
Please be careful with folders in your working directory with the same
535
558
name as your package as they may take precedence during imports.
0 commit comments