|
42 | 42 | from typing import TypeAlias |
43 | 43 |
|
44 | 44 | from _typeshed import SupportsWrite |
| 45 | + from typing_extensions import deprecated |
45 | 46 |
|
46 | 47 | # type-only import because of mutual dependence between these modules |
47 | 48 | from .cmd import Command |
48 | 49 | from .extension import Extension |
| 50 | +else: |
| 51 | + |
| 52 | + def deprecated(message): |
| 53 | + return lambda fn: fn |
| 54 | + |
49 | 55 |
|
50 | 56 | _CommandT = TypeVar("_CommandT", bound="Command") |
51 | 57 | _OptionsList: TypeAlias = list[ |
@@ -859,25 +865,27 @@ def get_command_class(self, command: str) -> type[Command]: |
859 | 865 | raise DistutilsModuleError(f"invalid command '{command}'") |
860 | 866 |
|
861 | 867 | @overload |
862 | | - def get_command_obj( |
863 | | - self, command: str, create: Literal[True] = True |
864 | | - ) -> Command: ... |
| 868 | + def get_command_obj(self, command: str, create: None = None) -> Command: ... |
| 869 | + @deprecated("The 'create' argument is deprecated and doesn't do anything.") |
865 | 870 | @overload |
866 | | - def get_command_obj( |
867 | | - self, command: str, create: Literal[False] |
868 | | - ) -> Command | None: ... |
869 | | - def get_command_obj(self, command: str, create: bool = True) -> Command | None: |
| 871 | + def get_command_obj(self, command: str, create: bool) -> Command: ... |
| 872 | + def get_command_obj(self, command: str, create: object = None) -> Command | None: |
870 | 873 | """Return the command object for 'command'. Normally this object |
871 | 874 | is cached on a previous call to 'get_command_obj()'; if no command |
872 | | - object for 'command' is in the cache, then we either create and |
873 | | - return it (if 'create' is true) or return None. |
| 875 | + object for 'command' is in the cache, then we create and |
| 876 | + return it. |
874 | 877 | """ |
| 878 | + if create is not None: |
| 879 | + warnings.warn( |
| 880 | + "The 'create' argument is deprecated and doesn't do anything.", |
| 881 | + DeprecationWarning, |
| 882 | + stacklevel=2, |
| 883 | + ) |
875 | 884 | cmd_obj = self.command_obj.get(command) |
876 | | - if not cmd_obj and create: |
| 885 | + if not cmd_obj: |
877 | 886 | if DEBUG: |
878 | 887 | self.announce( |
879 | | - "Distribution.get_command_obj(): " |
880 | | - f"creating '{command}' command object" |
| 888 | + f"Distribution.get_command_obj(): creating '{command}' command object" |
881 | 889 | ) |
882 | 890 |
|
883 | 891 | klass = self.get_command_class(command) |
|
0 commit comments