|
15 | 15 | import warnings
|
16 | 16 | from collections.abc import Iterable
|
17 | 17 | from email import message_from_file
|
18 |
| -from typing import TYPE_CHECKING, TypeVar, overload |
| 18 | +from typing import TYPE_CHECKING, Literal, TypeVar, overload |
19 | 19 |
|
20 | 20 | from packaging.utils import canonicalize_name, canonicalize_version
|
21 | 21 |
|
|
31 | 31 | from .util import check_environ, rfc822_escape, strtobool
|
32 | 32 |
|
33 | 33 | if TYPE_CHECKING:
|
| 34 | + # type-only import because of mutual dependence between these modules |
34 | 35 | from .cmd import Command
|
35 | 36 |
|
36 | 37 | _CommandT = TypeVar("_CommandT", bound="Command")
|
@@ -837,7 +838,15 @@ def get_command_class(self, command):
|
837 | 838 |
|
838 | 839 | raise DistutilsModuleError(f"invalid command '{command}'")
|
839 | 840 |
|
840 |
| - def get_command_obj(self, command, create=True): |
| 841 | + @overload |
| 842 | + def get_command_obj( |
| 843 | + self, command: str, create: Literal[True] = True |
| 844 | + ) -> Command: ... |
| 845 | + @overload |
| 846 | + def get_command_obj( |
| 847 | + self, command: str, create: Literal[False] |
| 848 | + ) -> Command | None: ... |
| 849 | + def get_command_obj(self, command: str, create: bool = True) -> Command | None: |
841 | 850 | """Return the command object for 'command'. Normally this object
|
842 | 851 | is cached on a previous call to 'get_command_obj()'; if no command
|
843 | 852 | object for 'command' is in the cache, then we either create and
|
|
0 commit comments