Skip to content

Commit 003361c

Browse files
authored
Make distutils.dist.Distribution.get_command_obj not return None by default (#11950)
1 parent 3e0269b commit 003361c

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

stdlib/distutils/dist.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite
22
from collections.abc import Iterable, Mapping
33
from distutils.cmd import Command
44
from re import Pattern
5-
from typing import IO, Any, ClassVar, TypeVar, overload
5+
from typing import IO, Any, ClassVar, Literal, TypeVar, overload
66
from typing_extensions import TypeAlias
77

88
command_re: Pattern[str]
@@ -63,7 +63,10 @@ class Distribution:
6363
def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ...
6464
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
6565
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
66-
def get_command_obj(self, command: str, create: bool = True) -> Command | None: ...
66+
@overload
67+
def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ...
68+
@overload
69+
def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ...
6770
global_options: ClassVar[_OptionsList]
6871
common_usage: ClassVar[str]
6972
display_options: ClassVar[_OptionsList]

stubs/setuptools/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ pkg_resources.PathMetadata.egg_info
33
pkg_resources.EggMetadata.loader
44
pkg_resources.ZipProvider.loader
55

6-
# 1 used for True as a default value
7-
setuptools._distutils.dist.Distribution.get_command_obj
8-
96
# Dynamically created in __init__
107
setuptools._distutils.dist.Distribution.get_name
118
setuptools._distutils.dist.Distribution.get_version

stubs/setuptools/setuptools/_distutils/dist.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite
22
from collections.abc import Iterable, Mapping
33
from re import Pattern
4-
from typing import IO, Any, ClassVar, TypeVar, overload
4+
from typing import IO, Any, ClassVar, Literal, TypeVar, overload
55
from typing_extensions import TypeAlias
66

77
from .cmd import Command
@@ -64,7 +64,10 @@ class Distribution:
6464
def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ...
6565
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
6666
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
67-
def get_command_obj(self, command: str, create: bool = True) -> Command | None: ...
67+
@overload
68+
def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ...
69+
@overload
70+
def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ...
6871
global_options: ClassVar[_OptionsList]
6972
common_usage: ClassVar[str]
7073
display_options: ClassVar[_OptionsList]

0 commit comments

Comments
 (0)