2626Again, this is not a formal definition! Just a "taste" of the module.
2727"""
2828
29+ from __future__ import annotations
30+
2931import io
3032import os
3133import shlex
3638import tempfile
3739import warnings
3840from pathlib import Path
39- from typing import Dict , Iterator , List , Optional , Tuple , Union , Iterable
41+ from typing import Dict , Iterator , List , Optional , Union , Iterable
4042
4143import setuptools
4244import distutils
@@ -113,7 +115,7 @@ def _get_immediate_subdirectories(a_dir):
113115 ]
114116
115117
116- def _file_with_extension (directory : StrPath , extension : Union [ str , Tuple [str , ...] ]):
118+ def _file_with_extension (directory : StrPath , extension : str | tuple [str , ...]):
117119 matching = (f for f in os .listdir (directory ) if f .endswith (extension ))
118120 try :
119121 (file ,) = matching
@@ -163,7 +165,7 @@ class _ConfigSettingsTranslator:
163165
164166 # See pypa/setuptools#1928 pypa/setuptools#2491
165167
166- def _get_config (self , key : str , config_settings : _ConfigSettings ) -> List [str ]:
168+ def _get_config (self , key : str , config_settings : _ConfigSettings ) -> list [str ]:
167169 """
168170 Get the value of a specific key in ``config_settings`` as a list of strings.
169171
@@ -371,7 +373,7 @@ def prepare_metadata_for_build_wheel(
371373 def _build_with_temp_dir (
372374 self ,
373375 setup_command : Iterable [str ],
374- result_extension : Union [ str , Tuple [str , ...] ],
376+ result_extension : str | tuple [str , ...],
375377 result_directory : StrPath ,
376378 config_settings : _ConfigSettings ,
377379 arbitrary_args : Iterable [str ] = (),
@@ -407,7 +409,7 @@ def build_wheel(
407409 self ,
408410 wheel_directory : StrPath ,
409411 config_settings : _ConfigSettings = None ,
410- metadata_directory : Optional [ StrPath ] = None ,
412+ metadata_directory : StrPath | None = None ,
411413 ):
412414 with suppress_known_deprecation ():
413415 return self ._build_with_temp_dir (
@@ -425,9 +427,7 @@ def build_sdist(
425427 ['sdist' , '--formats' , 'gztar' ], '.tar.gz' , sdist_directory , config_settings
426428 )
427429
428- def _get_dist_info_dir (
429- self , metadata_directory : Optional [StrPath ]
430- ) -> Optional [str ]:
430+ def _get_dist_info_dir (self , metadata_directory : StrPath | None ) -> str | None :
431431 if not metadata_directory :
432432 return None
433433 dist_info_candidates = list (Path (metadata_directory ).glob ("*.dist-info" ))
@@ -443,7 +443,7 @@ def build_editable(
443443 self ,
444444 wheel_directory : StrPath ,
445445 config_settings : _ConfigSettings = None ,
446- metadata_directory : Optional [ str ] = None ,
446+ metadata_directory : str | None = None ,
447447 ):
448448 # XXX can or should we hide our editable_wheel command normally?
449449 info_dir = self ._get_dist_info_dir (metadata_directory )
0 commit comments