Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type Distribution.get_command_obj to not return None with create=True #307

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions distutils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import warnings
from collections.abc import Iterable
from email import message_from_file
from typing import TYPE_CHECKING, TypeVar, overload
from typing import TYPE_CHECKING, Literal, TypeVar, overload

from packaging.utils import canonicalize_name, canonicalize_version

Expand All @@ -31,6 +31,7 @@
from .util import check_environ, rfc822_escape, strtobool

if TYPE_CHECKING:
# type-only import because of mutual dependence between these modules
from .cmd import Command

_CommandT = TypeVar("_CommandT", bound="Command")
Expand Down Expand Up @@ -837,7 +838,15 @@ def get_command_class(self, command):

raise DistutilsModuleError(f"invalid command '{command}'")

def get_command_obj(self, command, create=True):
@overload
def get_command_obj(
self, command: str, create: Literal[True] = True
) -> Command: ...
@overload
def get_command_obj(
self, command: str, create: Literal[False]
) -> Command | None: ...
def get_command_obj(self, command: str, create: bool = True) -> Command | None:
"""Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
object for 'command' is in the cache, then we either create and
Expand Down
Loading