1212import sys
1313from abc import abstractmethod
1414from collections .abc import Mapping
15- from typing import TYPE_CHECKING , TypeVar , overload
15+ from typing import TYPE_CHECKING , Literal , TypeVar , overload
1616
1717sys .path .extend (((vendor_path := os .path .join (os .path .dirname (os .path .dirname (__file__ )), 'setuptools' , '_vendor' )) not in sys .path ) * [vendor_path ]) # fmt: skip
1818# workaround for #4476
3030
3131import distutils .core
3232
33+ if TYPE_CHECKING :
34+ from .command .alias import alias
35+ from .command .bdist_egg import bdist_egg
36+ from .command .bdist_rpm import bdist_rpm
37+ from .command .bdist_wheel import bdist_wheel
38+ from .command .build import build
39+ from .command .build_clib import build_clib
40+ from .command .build_ext import build_ext
41+ from .command .build_py import build_py
42+ from .command .develop import develop
43+ from .command .dist_info import dist_info
44+ from .command .easy_install import easy_install
45+ from .command .editable_wheel import editable_wheel
46+ from .command .egg_info import egg_info
47+ from .command .install import install
48+ from .command .install_egg_info import install_egg_info
49+ from .command .install_lib import install_lib
50+ from .command .install_scripts import install_scripts
51+ from .command .rotate import rotate
52+ from .command .saveopts import saveopts
53+ from .command .sdist import sdist
54+ from .command .setopt import setopt
55+
3356__all__ = [
3457 'setup' ,
3558 'Distribution' ,
@@ -175,6 +198,200 @@ def __init__(self, dist: Distribution, **kw) -> None:
175198 super ().__init__ (dist )
176199 vars (self ).update (kw )
177200
201+ if TYPE_CHECKING :
202+ # Note: Commands that setuptools doesn't re-expose are considered deprecated (they must be imported from distutils directly)
203+ # So we're not listing them here. This list comes directly from the setuptools/command folder. Minus the test command.
204+ @overload # type: ignore[no-overload-impl] # This overrides from distutils
205+ def get_finalized_command ( # pyright: ignore[reportNoOverloadImplementation] # This overrides form distutils
206+ self , command : Literal ["alias" ], create : bool = True
207+ ) -> alias : ...
208+ @overload
209+ def get_finalized_command (
210+ self , command : Literal ["bdist_egg" ], create : bool = True
211+ ) -> bdist_egg : ...
212+ @overload
213+ def get_finalized_command (
214+ self , command : Literal ["bdist_rpm" ], create : bool = True
215+ ) -> bdist_rpm : ...
216+ @overload
217+ def get_finalized_command (
218+ self , command : Literal ["bdist_wheel" ], create : bool = True
219+ ) -> bdist_wheel : ...
220+ @overload
221+ def get_finalized_command (
222+ self , command : Literal ["build" ], create : bool = True
223+ ) -> build : ...
224+ @overload
225+ def get_finalized_command (
226+ self , command : Literal ["build_clib" ], create : bool = True
227+ ) -> build_clib : ...
228+ @overload
229+ def get_finalized_command (
230+ self , command : Literal ["build_ext" ], create : bool = True
231+ ) -> build_ext : ...
232+ @overload
233+ def get_finalized_command (
234+ self , command : Literal ["build_py" ], create : bool = True
235+ ) -> build_py : ...
236+ @overload
237+ def get_finalized_command (
238+ self , command : Literal ["develop" ], create : bool = True
239+ ) -> develop : ...
240+ @overload
241+ def get_finalized_command (
242+ self , command : Literal ["dist_info" ], create : bool = True
243+ ) -> dist_info : ...
244+ @overload
245+ def get_finalized_command (
246+ self , command : Literal ["easy_install" ], create : bool = True
247+ ) -> easy_install : ...
248+ @overload
249+ def get_finalized_command (
250+ self , command : Literal ["editable_wheel" ], create : bool = True
251+ ) -> editable_wheel : ...
252+ @overload
253+ def get_finalized_command (
254+ self , command : Literal ["egg_info" ], create : bool = True
255+ ) -> egg_info : ...
256+ @overload
257+ def get_finalized_command (
258+ self , command : Literal ["install" ], create : bool = True
259+ ) -> install : ...
260+ @overload
261+ def get_finalized_command (
262+ self , command : Literal ["install_egg_info" ], create : bool = True
263+ ) -> install_egg_info : ...
264+ @overload
265+ def get_finalized_command (
266+ self , command : Literal ["install_lib" ], create : bool = True
267+ ) -> install_lib : ...
268+ @overload
269+ def get_finalized_command (
270+ self , command : Literal ["install_scripts" ], create : bool = True
271+ ) -> install_scripts : ...
272+ @overload
273+ def get_finalized_command (
274+ self , command : Literal ["rotate" ], create : bool = True
275+ ) -> rotate : ...
276+ @overload
277+ def get_finalized_command (
278+ self , command : Literal ["saveopts" ], create : bool = True
279+ ) -> saveopts : ...
280+ @overload
281+ def get_finalized_command (
282+ self , command : Literal ["sdist" ], create : bool = True
283+ ) -> sdist : ...
284+ @overload
285+ def get_finalized_command (
286+ self , command : Literal ["setopt" ], create : bool = True
287+ ) -> setopt : ...
288+ @overload
289+ def get_finalized_command (
290+ self , command : str , create : bool = True
291+ ) -> Command : ...
292+
293+ @overload
294+ def reinitialize_command (
295+ self , command : Literal ["alias" ], reinit_subcommands : bool = False , ** kw
296+ ) -> alias : ...
297+ @overload
298+ def reinitialize_command (
299+ self , command : Literal ["bdist_egg" ], reinit_subcommands : bool = False , ** kw
300+ ) -> bdist_egg : ...
301+ @overload
302+ def reinitialize_command (
303+ self , command : Literal ["bdist_rpm" ], reinit_subcommands : bool = False , ** kw
304+ ) -> bdist_rpm : ...
305+ @overload
306+ def reinitialize_command (
307+ self ,
308+ command : Literal ["bdist_wheel" ],
309+ reinit_subcommands : bool = False ,
310+ ** kw ,
311+ ) -> bdist_wheel : ...
312+ @overload
313+ def reinitialize_command (
314+ self , command : Literal ["build" ], reinit_subcommands : bool = False , ** kw
315+ ) -> build : ...
316+ @overload
317+ def reinitialize_command (
318+ self , command : Literal ["build_clib" ], reinit_subcommands : bool = False , ** kw
319+ ) -> build_clib : ...
320+ @overload
321+ def reinitialize_command (
322+ self , command : Literal ["build_ext" ], reinit_subcommands : bool = False , ** kw
323+ ) -> build_ext : ...
324+ @overload
325+ def reinitialize_command (
326+ self , command : Literal ["build_py" ], reinit_subcommands : bool = False , ** kw
327+ ) -> build_py : ...
328+ @overload
329+ def reinitialize_command (
330+ self , command : Literal ["develop" ], reinit_subcommands : bool = False , ** kw
331+ ) -> develop : ...
332+ @overload
333+ def reinitialize_command (
334+ self , command : Literal ["dist_info" ], reinit_subcommands : bool = False , ** kw
335+ ) -> dist_info : ...
336+ @overload
337+ def reinitialize_command (
338+ self ,
339+ command : Literal ["easy_install" ],
340+ reinit_subcommands : bool = False ,
341+ ** kw ,
342+ ) -> easy_install : ...
343+ @overload
344+ def reinitialize_command (
345+ self ,
346+ command : Literal ["editable_wheel" ],
347+ reinit_subcommands : bool = False ,
348+ ** kw ,
349+ ) -> editable_wheel : ...
350+ @overload
351+ def reinitialize_command (
352+ self , command : Literal ["egg_info" ], reinit_subcommands : bool = False , ** kw
353+ ) -> egg_info : ...
354+ @overload
355+ def reinitialize_command (
356+ self , command : Literal ["install" ], reinit_subcommands : bool = False , ** kw
357+ ) -> install : ...
358+ @overload
359+ def reinitialize_command (
360+ self ,
361+ command : Literal ["install_egg_info" ],
362+ reinit_subcommands : bool = False ,
363+ ** kw ,
364+ ) -> install_egg_info : ...
365+ @overload
366+ def reinitialize_command (
367+ self ,
368+ command : Literal ["install_lib" ],
369+ reinit_subcommands : bool = False ,
370+ ** kw ,
371+ ) -> install_lib : ...
372+ @overload
373+ def reinitialize_command (
374+ self ,
375+ command : Literal ["install_scripts" ],
376+ reinit_subcommands : bool = False ,
377+ ** kw ,
378+ ) -> install_scripts : ...
379+ @overload
380+ def reinitialize_command (
381+ self , command : Literal ["rotate" ], reinit_subcommands : bool = False , ** kw
382+ ) -> rotate : ...
383+ @overload
384+ def reinitialize_command (
385+ self , command : Literal ["saveopts" ], reinit_subcommands : bool = False , ** kw
386+ ) -> saveopts : ...
387+ @overload
388+ def reinitialize_command (
389+ self , command : Literal ["sdist" ], reinit_subcommands : bool = False , ** kw
390+ ) -> sdist : ...
391+ @overload
392+ def reinitialize_command (
393+ self , command : Literal ["setopt" ], reinit_subcommands : bool = False , ** kw
394+ ) -> setopt : ...
178395 @overload
179396 def reinitialize_command (
180397 self , command : str , reinit_subcommands : bool = False , ** kw
@@ -188,7 +405,7 @@ def reinitialize_command(
188405 ) -> Command | _Command :
189406 cmd = _Command .reinitialize_command (self , command , reinit_subcommands )
190407 vars (cmd ).update (kw )
191- return cmd # pyright: ignore[reportReturnType] # pypa/distutils#307
408+ return cmd
192409
193410 @abstractmethod
194411 def initialize_options (self ) -> None :
0 commit comments