39
39
import warnings
40
40
from collections .abc import Iterable , Iterator , Mapping
41
41
from pathlib import Path
42
- from typing import TYPE_CHECKING , Union
42
+ from typing import TYPE_CHECKING , NoReturn , Union
43
43
44
44
import setuptools
45
45
@@ -74,14 +74,14 @@ def __init__(self, specifiers) -> None:
74
74
75
75
76
76
class Distribution (setuptools .dist .Distribution ):
77
- def fetch_build_eggs (self , specifiers ):
77
+ def fetch_build_eggs (self , specifiers ) -> NoReturn :
78
78
specifier_list = list (parse_strings (specifiers ))
79
79
80
80
raise SetupRequirementsError (specifier_list )
81
81
82
82
@classmethod
83
83
@contextlib .contextmanager
84
- def patch (cls ):
84
+ def patch (cls ) -> Iterator [ None ] :
85
85
"""
86
86
Replace
87
87
distutils.dist.Distribution with this class
@@ -304,7 +304,7 @@ def _get_build_requires(
304
304
305
305
return requirements
306
306
307
- def run_setup (self , setup_script : str = 'setup.py' ):
307
+ def run_setup (self , setup_script : str = 'setup.py' ) -> None :
308
308
# Note that we can reuse our build directory between calls
309
309
# Correctness comes first, then optimization later
310
310
__file__ = os .path .abspath (setup_script )
@@ -327,10 +327,14 @@ def run_setup(self, setup_script: str = 'setup.py'):
327
327
"setup-py-deprecated.html" ,
328
328
)
329
329
330
- def get_requires_for_build_wheel (self , config_settings : _ConfigSettings = None ):
330
+ def get_requires_for_build_wheel (
331
+ self , config_settings : _ConfigSettings = None
332
+ ) -> list [str ]:
331
333
return self ._get_build_requires (config_settings , requirements = [])
332
334
333
- def get_requires_for_build_sdist (self , config_settings : _ConfigSettings = None ):
335
+ def get_requires_for_build_sdist (
336
+ self , config_settings : _ConfigSettings = None
337
+ ) -> list [str ]:
334
338
return self ._get_build_requires (config_settings , requirements = [])
335
339
336
340
def _bubble_up_info_directory (
@@ -361,7 +365,7 @@ def _find_info_directory(self, metadata_directory: StrPath, suffix: str) -> Path
361
365
362
366
def prepare_metadata_for_build_wheel (
363
367
self , metadata_directory : StrPath , config_settings : _ConfigSettings = None
364
- ):
368
+ ) -> str :
365
369
sys .argv = [
366
370
* sys .argv [:1 ],
367
371
* self ._global_args (config_settings ),
@@ -417,7 +421,7 @@ def build_wheel(
417
421
wheel_directory : StrPath ,
418
422
config_settings : _ConfigSettings = None ,
419
423
metadata_directory : StrPath | None = None ,
420
- ):
424
+ ) -> str :
421
425
def _build (cmd : list [str ]):
422
426
with suppress_known_deprecation ():
423
427
return self ._build_with_temp_dir (
@@ -442,7 +446,7 @@ def _build(cmd: list[str]):
442
446
443
447
def build_sdist (
444
448
self , sdist_directory : StrPath , config_settings : _ConfigSettings = None
445
- ):
449
+ ) -> str :
446
450
return self ._build_with_temp_dir (
447
451
['sdist' , '--formats' , 'gztar' ], '.tar.gz' , sdist_directory , config_settings
448
452
)
@@ -459,7 +463,7 @@ def build_editable(
459
463
wheel_directory : StrPath ,
460
464
config_settings : _ConfigSettings = None ,
461
465
metadata_directory : StrPath | None = None ,
462
- ):
466
+ ) -> str :
463
467
# XXX can or should we hide our editable_wheel command normally?
464
468
info_dir = self ._get_dist_info_dir (metadata_directory )
465
469
opts = ["--dist-info-dir" , info_dir ] if info_dir else []
@@ -469,12 +473,14 @@ def build_editable(
469
473
cmd , ".whl" , wheel_directory , config_settings
470
474
)
471
475
472
- def get_requires_for_build_editable (self , config_settings : _ConfigSettings = None ):
476
+ def get_requires_for_build_editable (
477
+ self , config_settings : _ConfigSettings = None
478
+ ) -> list [str ]:
473
479
return self .get_requires_for_build_wheel (config_settings )
474
480
475
481
def prepare_metadata_for_build_editable (
476
482
self , metadata_directory : StrPath , config_settings : _ConfigSettings = None
477
- ):
483
+ ) -> str :
478
484
return self .prepare_metadata_for_build_wheel (
479
485
metadata_directory , config_settings
480
486
)
@@ -492,7 +498,7 @@ class _BuildMetaLegacyBackend(_BuildMetaBackend):
492
498
and will eventually be removed.
493
499
"""
494
500
495
- def run_setup (self , setup_script : str = 'setup.py' ):
501
+ def run_setup (self , setup_script : str = 'setup.py' ) -> None :
496
502
# In order to maintain compatibility with scripts assuming that
497
503
# the setup.py script is in a directory on the PYTHONPATH, inject
498
504
# '' into sys.path. (pypa/setuptools#1642)
0 commit comments