3939import warnings
4040from collections .abc import Iterable , Iterator , Mapping
4141from pathlib import Path
42- from typing import TYPE_CHECKING , Union
42+ from typing import TYPE_CHECKING , NoReturn , Union
4343
4444import setuptools
4545
@@ -74,14 +74,14 @@ def __init__(self, specifiers) -> None:
7474
7575
7676class Distribution (setuptools .dist .Distribution ):
77- def fetch_build_eggs (self , specifiers ):
77+ def fetch_build_eggs (self , specifiers ) -> NoReturn :
7878 specifier_list = list (parse_strings (specifiers ))
7979
8080 raise SetupRequirementsError (specifier_list )
8181
8282 @classmethod
8383 @contextlib .contextmanager
84- def patch (cls ):
84+ def patch (cls ) -> Iterator [ None ] :
8585 """
8686 Replace
8787 distutils.dist.Distribution with this class
@@ -304,7 +304,7 @@ def _get_build_requires(
304304
305305 return requirements
306306
307- def run_setup (self , setup_script : str = 'setup.py' ):
307+ def run_setup (self , setup_script : str = 'setup.py' ) -> None :
308308 # Note that we can reuse our build directory between calls
309309 # Correctness comes first, then optimization later
310310 __file__ = os .path .abspath (setup_script )
@@ -327,10 +327,14 @@ def run_setup(self, setup_script: str = 'setup.py'):
327327 "setup-py-deprecated.html" ,
328328 )
329329
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 ]:
331333 return self ._get_build_requires (config_settings , requirements = [])
332334
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 ]:
334338 return self ._get_build_requires (config_settings , requirements = [])
335339
336340 def _bubble_up_info_directory (
@@ -361,7 +365,7 @@ def _find_info_directory(self, metadata_directory: StrPath, suffix: str) -> Path
361365
362366 def prepare_metadata_for_build_wheel (
363367 self , metadata_directory : StrPath , config_settings : _ConfigSettings = None
364- ):
368+ ) -> str :
365369 sys .argv = [
366370 * sys .argv [:1 ],
367371 * self ._global_args (config_settings ),
@@ -417,7 +421,7 @@ def build_wheel(
417421 wheel_directory : StrPath ,
418422 config_settings : _ConfigSettings = None ,
419423 metadata_directory : StrPath | None = None ,
420- ):
424+ ) -> str :
421425 def _build (cmd : list [str ]):
422426 with suppress_known_deprecation ():
423427 return self ._build_with_temp_dir (
@@ -442,7 +446,7 @@ def _build(cmd: list[str]):
442446
443447 def build_sdist (
444448 self , sdist_directory : StrPath , config_settings : _ConfigSettings = None
445- ):
449+ ) -> str :
446450 return self ._build_with_temp_dir (
447451 ['sdist' , '--formats' , 'gztar' ], '.tar.gz' , sdist_directory , config_settings
448452 )
@@ -459,7 +463,7 @@ def build_editable(
459463 wheel_directory : StrPath ,
460464 config_settings : _ConfigSettings = None ,
461465 metadata_directory : StrPath | None = None ,
462- ):
466+ ) -> str :
463467 # XXX can or should we hide our editable_wheel command normally?
464468 info_dir = self ._get_dist_info_dir (metadata_directory )
465469 opts = ["--dist-info-dir" , info_dir ] if info_dir else []
@@ -469,12 +473,14 @@ def build_editable(
469473 cmd , ".whl" , wheel_directory , config_settings
470474 )
471475
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 ]:
473479 return self .get_requires_for_build_wheel (config_settings )
474480
475481 def prepare_metadata_for_build_editable (
476482 self , metadata_directory : StrPath , config_settings : _ConfigSettings = None
477- ):
483+ ) -> str :
478484 return self .prepare_metadata_for_build_wheel (
479485 metadata_directory , config_settings
480486 )
@@ -492,7 +498,7 @@ class _BuildMetaLegacyBackend(_BuildMetaBackend):
492498 and will eventually be removed.
493499 """
494500
495- def run_setup (self , setup_script : str = 'setup.py' ):
501+ def run_setup (self , setup_script : str = 'setup.py' ) -> None :
496502 # In order to maintain compatibility with scripts assuming that
497503 # the setup.py script is in a directory on the PYTHONPATH, inject
498504 # '' into sys.path. (pypa/setuptools#1642)
0 commit comments