3838import tokenize
3939import warnings
4040from pathlib import Path
41- from typing import TYPE_CHECKING , Dict , Iterable , Iterator , List , Union
41+ from typing import TYPE_CHECKING , Iterable , Iterator , List , Mapping , Union
4242
4343import setuptools
4444
5353if TYPE_CHECKING :
5454 from typing_extensions import TypeAlias
5555
56-
5756__all__ = [
5857 'get_requires_for_build_sdist' ,
5958 'get_requires_for_build_wheel' ,
@@ -147,7 +146,7 @@ def suppress_known_deprecation():
147146 yield
148147
149148
150- _ConfigSettings : TypeAlias = Union [Dict [str , Union [str , List [str ], None ]], None ]
149+ _ConfigSettings : TypeAlias = Union [Mapping [str , Union [str , List [str ], None ]], None ]
151150"""
152151Currently the user can run::
153152
@@ -291,7 +290,9 @@ def _arbitrary_args(self, config_settings: _ConfigSettings) -> Iterator[str]:
291290
292291
293292class _BuildMetaBackend (_ConfigSettingsTranslator ):
294- def _get_build_requires (self , config_settings , requirements ):
293+ def _get_build_requires (
294+ self , config_settings : _ConfigSettings , requirements : list [str ]
295+ ):
295296 sys .argv = [
296297 * sys .argv [:1 ],
297298 * self ._global_args (config_settings ),
@@ -305,7 +306,7 @@ def _get_build_requires(self, config_settings, requirements):
305306
306307 return requirements
307308
308- def run_setup (self , setup_script = 'setup.py' ):
309+ def run_setup (self , setup_script : str = 'setup.py' ):
309310 # Note that we can reuse our build directory between calls
310311 # Correctness comes first, then optimization later
311312 __file__ = os .path .abspath (setup_script )
@@ -328,13 +329,15 @@ def run_setup(self, setup_script='setup.py'):
328329 "setup-py-deprecated.html" ,
329330 )
330331
331- def get_requires_for_build_wheel (self , config_settings = None ):
332+ def get_requires_for_build_wheel (self , config_settings : _ConfigSettings = None ):
332333 return self ._get_build_requires (config_settings , requirements = [])
333334
334- def get_requires_for_build_sdist (self , config_settings = None ):
335+ def get_requires_for_build_sdist (self , config_settings : _ConfigSettings = None ):
335336 return self ._get_build_requires (config_settings , requirements = [])
336337
337- def _bubble_up_info_directory (self , metadata_directory : str , suffix : str ) -> str :
338+ def _bubble_up_info_directory (
339+ self , metadata_directory : StrPath , suffix : str
340+ ) -> str :
338341 """
339342 PEP 517 requires that the .dist-info directory be placed in the
340343 metadata_directory. To comply, we MUST copy the directory to the root.
@@ -347,7 +350,7 @@ def _bubble_up_info_directory(self, metadata_directory: str, suffix: str) -> str
347350 # PEP 517 allow other files and dirs to exist in metadata_directory
348351 return info_dir .name
349352
350- def _find_info_directory (self , metadata_directory : str , suffix : str ) -> Path :
353+ def _find_info_directory (self , metadata_directory : StrPath , suffix : str ) -> Path :
351354 for parent , dirs , _ in os .walk (metadata_directory ):
352355 candidates = [f for f in dirs if f .endswith (suffix )]
353356
@@ -359,14 +362,14 @@ def _find_info_directory(self, metadata_directory: str, suffix: str) -> Path:
359362 raise errors .InternalError (msg )
360363
361364 def prepare_metadata_for_build_wheel (
362- self , metadata_directory , config_settings = None
365+ self , metadata_directory : StrPath , config_settings : _ConfigSettings = None
363366 ):
364367 sys .argv = [
365368 * sys .argv [:1 ],
366369 * self ._global_args (config_settings ),
367370 "dist_info" ,
368371 "--output-dir" ,
369- metadata_directory ,
372+ str ( metadata_directory ) ,
370373 "--keep-egg-info" ,
371374 ]
372375 with no_install_setup_requires ():
@@ -462,7 +465,7 @@ def build_editable(
462465 self ,
463466 wheel_directory : StrPath ,
464467 config_settings : _ConfigSettings = None ,
465- metadata_directory : str | None = None ,
468+ metadata_directory : StrPath | None = None ,
466469 ):
467470 # XXX can or should we hide our editable_wheel command normally?
468471 info_dir = self ._get_dist_info_dir (metadata_directory )
@@ -473,11 +476,13 @@ def build_editable(
473476 cmd , ".whl" , wheel_directory , config_settings
474477 )
475478
476- def get_requires_for_build_editable (self , config_settings = None ):
479+ def get_requires_for_build_editable (
480+ self , config_settings : _ConfigSettings = None
481+ ):
477482 return self .get_requires_for_build_wheel (config_settings )
478483
479484 def prepare_metadata_for_build_editable (
480- self , metadata_directory , config_settings = None
485+ self , metadata_directory : StrPath , config_settings : _ConfigSettings = None
481486 ):
482487 return self .prepare_metadata_for_build_wheel (
483488 metadata_directory , config_settings
@@ -496,7 +501,7 @@ class _BuildMetaLegacyBackend(_BuildMetaBackend):
496501 and will eventually be removed.
497502 """
498503
499- def run_setup (self , setup_script = 'setup.py' ):
504+ def run_setup (self , setup_script : str = 'setup.py' ):
500505 # In order to maintain compatibility with scripts assuming that
501506 # the setup.py script is in a directory on the PYTHONPATH, inject
502507 # '' into sys.path. (pypa/setuptools#1642)
0 commit comments