|
3 | 3 | Provides the Distribution class, which represents the module distribution
|
4 | 4 | being built/installed/distributed.
|
5 | 5 | """
|
| 6 | +from __future__ import annotations |
6 | 7 |
|
7 | 8 | import contextlib
|
8 | 9 | import logging
|
9 | 10 | import os
|
10 | 11 | import pathlib
|
11 | 12 | import re
|
12 | 13 | import sys
|
| 14 | +from typing import TYPE_CHECKING, Literal, overload |
13 | 15 | import warnings
|
14 | 16 | from collections.abc import Iterable
|
15 | 17 | from email import message_from_file
|
|
27 | 29 | from .fancy_getopt import FancyGetopt, translate_longopt
|
28 | 30 | from .util import check_environ, rfc822_escape, strtobool
|
29 | 31 |
|
| 32 | +if TYPE_CHECKING: |
| 33 | + # type-only import because of mutual dependence between these modules |
| 34 | + from .cmd import Command |
| 35 | + |
30 | 36 | # Regex to define acceptable Distutils command names. This is not *quite*
|
31 | 37 | # the same as a Python NAME -- I don't allow leading underscores. The fact
|
32 | 38 | # that they're very similar is no coincidence; the default naming scheme is
|
@@ -829,7 +835,11 @@ def get_command_class(self, command):
|
829 | 835 |
|
830 | 836 | raise DistutilsModuleError(f"invalid command '{command}'")
|
831 | 837 |
|
832 |
| - def get_command_obj(self, command, create=True): |
| 838 | + @overload |
| 839 | + def get_command_obj(self, command: str, create: Literal[True] = True) -> Command: ... |
| 840 | + @overload |
| 841 | + def get_command_obj(self, command: str, create: Literal[False]) -> Command | None: ... |
| 842 | + def get_command_obj(self, command: str, create: bool = True) -> Command | None: |
833 | 843 | """Return the command object for 'command'. Normally this object
|
834 | 844 | is cached on a previous call to 'get_command_obj()'; if no command
|
835 | 845 | object for 'command' is in the cache, then we either create and
|
|
0 commit comments