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