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

Setuptools stubs update from merging upstream #12400

Merged
merged 10 commits into from
Jul 25, 2024
10 changes: 7 additions & 3 deletions stdlib/distutils/cmd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ from abc import abstractmethod
from collections.abc import Callable, Iterable
from distutils.dist import Distribution
from distutils.file_util import _BytesPathT, _StrPathT
from typing import Any, ClassVar, Literal, overload
from typing import Any, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack

_CommandT = TypeVar("_CommandT", bound=Command)
_Ts = TypeVarTuple("_Ts")

class Command:
Expand All @@ -22,13 +23,16 @@ class Command:
def announce(self, msg: str, level: int = 1) -> None: ...
def debug_print(self, msg: str) -> None: ...
def ensure_string(self, option: str, default: str | None = None) -> None: ...
def ensure_string_list(self, option: str | list[str]) -> None: ...
def ensure_string_list(self, option: str) -> None: ...
def ensure_filename(self, option: str) -> None: ...
def ensure_dirname(self, option: str) -> None: ...
def get_command_name(self) -> str: ...
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ...
def reinitialize_command(self, command: Command | str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ...
@overload
def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ...
@overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ...
def run_command(self, command: str) -> None: ...
def get_sub_commands(self) -> list[str]: ...
def warn(self, msg: str) -> None: ...
Expand Down
11 changes: 8 additions & 3 deletions stubs/setuptools/setuptools/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from _typeshed import Incomplete, StrPath
from abc import abstractmethod
from collections.abc import Iterable, Mapping, Sequence
from typing import Any
from typing import Any, TypeVar, overload

from ._distutils.cmd import Command as _Command
from .depends import Require as Require
from .dist import Distribution as Distribution
from .extension import Extension as Extension
from .warnings import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning

_CommandT = TypeVar("_CommandT", bound=_Command)

__all__ = [
"setup",
"Distribution",
Expand Down Expand Up @@ -76,8 +78,11 @@ class Command(_Command):
distribution: Distribution
# Any: Dynamic command subclass attributes
def __init__(self, dist: Distribution, **kw: Any) -> None: ...
def ensure_string_list(self, option: str | list[str]) -> None: ...
def reinitialize_command(self, command: _Command | str, reinit_subcommands: bool = False, **kw: Any) -> _Command: ... # type: ignore[override]
def ensure_string_list(self, option: str) -> None: ...
@overload # type: ignore[override] # Extra **kw param
def reinitialize_command(self, command: str, reinit_subcommands: bool = False, **kw) -> _Command: ...
@overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False, **kw) -> _CommandT: ...
@abstractmethod
def initialize_options(self) -> None: ...
@abstractmethod
Expand Down
8 changes: 6 additions & 2 deletions stubs/setuptools/setuptools/_distutils/cmd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from .dist import Distribution

_StrPathT = TypeVar("_StrPathT", bound=StrPath)
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath)
_CommandT = TypeVar("_CommandT", bound=Command)
_Ts = TypeVarTuple("_Ts")

class Command:
Expand All @@ -25,13 +26,16 @@ class Command:
def announce(self, msg: str, level: int = ...) -> None: ...
def debug_print(self, msg: str) -> None: ...
def ensure_string(self, option: str, default: str | None = ...) -> None: ...
def ensure_string_list(self, option: str | list[str]) -> None: ...
def ensure_string_list(self, option: str) -> None: ...
def ensure_filename(self, option: str) -> None: ...
def ensure_dirname(self, option: str) -> None: ...
def get_command_name(self) -> str: ...
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
def get_finalized_command(self, command: str, create: bool = True) -> Command: ...
def reinitialize_command(self, command: Command | str, reinit_subcommands: bool = False) -> Command: ...
@overload
def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ...
@overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ...
def run_command(self, command: str) -> None: ...
def get_sub_commands(self) -> list[str]: ...
def warn(self, msg: str) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/setuptools/setuptools/_distutils/command/bdist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ListCompat(dict[str, tuple[str, str]]):

class bdist(Command):
description: ClassVar[str]
user_options: ClassVar[list[tuple[str | None, str | None, str | None]]]
user_options: ClassVar[list[tuple[str, str | None, str | None]]]
boolean_options: ClassVar[list[str]]
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]]
no_format_option: ClassVar[tuple[str, ...]]
Expand Down
20 changes: 8 additions & 12 deletions stubs/setuptools/setuptools/build_meta.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,18 @@ class Distribution(dist.Distribution):

class _BuildMetaBackend:
def run_setup(self, setup_script: str = "setup.py") -> None: ...
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
def prepare_metadata_for_build_wheel(
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
) -> str: ...
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings = None) -> list[str]: ...
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings = None) -> list[str]: ...
def prepare_metadata_for_build_wheel(self, metadata_directory: str, config_settings: _ConfigSettings = None) -> str: ...
def build_wheel(
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: StrPath | None = None
self, wheel_directory: StrPath, config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None
) -> str: ...
def build_sdist(self, sdist_directory: StrPath, config_settings: _ConfigSettings | None = None) -> str: ...
def build_sdist(self, sdist_directory: StrPath, config_settings: _ConfigSettings = None) -> str: ...
def build_editable(
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: str | None = None
) -> str: ...
def get_requires_for_build_editable(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
def prepare_metadata_for_build_editable(
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
self, wheel_directory: StrPath, config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None
) -> str: ...
def get_requires_for_build_editable(self, config_settings: _ConfigSettings = None) -> list[str]: ...
def prepare_metadata_for_build_editable(self, metadata_directory: str, config_settings: _ConfigSettings = None) -> str: ...

class _BuildMetaLegacyBackend(_BuildMetaBackend):
def run_setup(self, setup_script: str = "setup.py") -> None: ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/setuptools/setuptools/command/build_py.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class build_py(orig.build_py):
package_data: dict[str, list[str]]
exclude_package_data: dict[Incomplete, Incomplete]
def finalize_options(self) -> None: ...
def copy_file( # type: ignore[override]
def copy_file( # type: ignore[override] # No overload, str support only
self,
infile: StrPath,
outfile: _StrPathT,
preserve_mode: bool = True,
preserve_times: bool = True,
link: str | None = None,
level=1,
level: int = 1,
) -> tuple[_StrPathT | str, bool]: ...
def run(self) -> None: ...
data_files: list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]
def __getattr__(self, attr: str): ...
def build_module(self, module, module_file, package): ...
def get_data_files_without_manifest(self) -> list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]: ...
def find_data_files(self, package, src_dir): ...
def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override]
def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override] # Using a real boolean instead of 0|1
def build_package_data(self) -> None: ...
manifest_files: dict[Incomplete, Incomplete]
def get_output_mapping(self) -> dict[str, str]: ...
Expand Down
28 changes: 15 additions & 13 deletions stubs/setuptools/setuptools/command/easy_install.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Iterator
from typing import ClassVar, TypedDict
from typing import Any, ClassVar, Literal, TypedDict, type_check_only
from typing_extensions import Self

from pkg_resources import Environment
from setuptools.package_index import PackageIndex

from .. import Command, SetuptoolsDeprecationWarning

Expand All @@ -15,7 +16,7 @@ class easy_install(Command):
user_options: ClassVar[list[tuple[str, str | None, str]]]
boolean_options: ClassVar[list[str]]
negative_opt: ClassVar[dict[str, str]]
create_index: Incomplete
create_index: ClassVar[type[PackageIndex]]
user: bool
zip_ok: Incomplete
install_dir: Incomplete
Expand All @@ -36,22 +37,22 @@ class easy_install(Command):
install_data: Incomplete
install_base: Incomplete
install_platbase: Incomplete
install_userbase: Incomplete
install_usersite: Incomplete
install_userbase: str | None
install_usersite: str | None
no_find_links: Incomplete
package_index: Incomplete
pth_file: Incomplete
site_dirs: Incomplete
installed_projects: Incomplete
verbose: Incomplete
verbose: bool | Literal[0, 1]
def initialize_options(self) -> None: ...
def delete_blockers(self, blockers) -> None: ...
config_vars: Incomplete
config_vars: dict[str, Any]
script_dir: Incomplete
all_site_dirs: Incomplete
shadow_path: Incomplete
local_index: Incomplete
outputs: Incomplete
all_site_dirs: list[str]
shadow_path: list[str]
local_index: Environment
outputs: list[Incomplete]
def finalize_options(self) -> None: ...
def expand_basedirs(self) -> None: ...
def expand_dirs(self) -> None: ...
Expand Down Expand Up @@ -98,7 +99,7 @@ def get_exe_prefixes(exe_filename): ...
class PthDistributions(Environment):
dirty: bool
filename: Incomplete
sitedirs: Incomplete
sitedirs: list[str]
basedir: Incomplete
paths: list[str]
def __init__(self, filename, sitedirs=()) -> None: ...
Expand All @@ -108,9 +109,10 @@ class PthDistributions(Environment):
def make_relative(self, path): ...

class RewritePthDistributions(PthDistributions):
prelude: Incomplete
postlude: Incomplete
prelude: str
postlude: str

@type_check_only
class _SplitArgs(TypedDict, total=False):
comments: bool
posix: bool
Expand Down
28 changes: 14 additions & 14 deletions stubs/setuptools/setuptools/command/editable_wheel.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete, StrPath
from collections.abc import Iterator
from collections.abc import Iterator, Mapping
from enum import Enum
from pathlib import Path
from types import TracebackType
Expand Down Expand Up @@ -28,45 +28,45 @@ class editable_wheel(Command):
project_dir: Incomplete
mode: Incomplete
def initialize_options(self) -> None: ...
package_dir: Incomplete
package_dir: dict[Incomplete, Incomplete]
def finalize_options(self) -> None: ...
def run(self) -> None: ...

class EditableStrategy(Protocol):
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]) -> None: ...
def __enter__(self): ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...

class _StaticPth:
dist: Incomplete
name: Incomplete
path_entries: Incomplete
dist: Distribution
name: str
path_entries: list[Path]
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...

class _LinkTree(_StaticPth):
auxiliary_dir: Incomplete
build_lib: Incomplete
auxiliary_dir: Path
build_lib: Path
def __init__(self, dist: Distribution, name: str, auxiliary_dir: StrPath, build_lib: StrPath) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...

class _TopLevelFinder:
dist: Incomplete
name: Incomplete
dist: Distribution
name: str
def __init__(self, dist: Distribution, name: str) -> None: ...
def template_vars(self) -> tuple[str, str, dict[str, str], dict[str, list[str]]]: ...
def get_implementation(self) -> Iterator[tuple[str, bytes]]: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
Expand All @@ -77,7 +77,7 @@ class _NamespaceInstaller(namespaces.Installer):
src_root: Incomplete
installation_dir: Incomplete
editable_name: Incomplete
outputs: Incomplete
outputs: list[Incomplete]
dry_run: bool
def __init__(self, distribution, installation_dir, editable_name, src_root) -> None: ...

Expand Down
3 changes: 1 addition & 2 deletions stubs/setuptools/setuptools/command/egg_info.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class egg_info(InfoCommon, Command):
egg_name: Incomplete
egg_info: Incomplete
egg_version: Incomplete
broken_egg_info: bool
def initialize_options(self) -> None: ...
@property
def tag_svn_revision(self) -> None: ...
Expand Down Expand Up @@ -65,7 +64,7 @@ class manifest_maker(sdist):
force_manifest: bool
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
filelist: Incomplete
filelist: FileList
def run(self) -> None: ...
def write_manifest(self) -> None: ...
def warn(self, msg) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/setuptools/setuptools/command/install.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class install(orig.install):
# Any to work around variance issues
new_commands: list[tuple[str, Callable[[Any], bool]] | None]
old_and_unmanageable: Incomplete
single_version_externally_managed: Incomplete
single_version_externally_managed: bool | None
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
path_file: Incomplete
Expand Down
6 changes: 3 additions & 3 deletions stubs/setuptools/setuptools/command/install_lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class install_lib(orig.install_lib):
self,
infile: StrPath,
outfile: str,
preserve_mode: bool = True, # type: ignore[override]
preserve_times: bool = True, # type: ignore[override]
preserve_symlinks: bool = False, # type: ignore[override]
preserve_mode: bool = True,
preserve_times: bool = True,
preserve_symlinks: bool = False,
level: Unused = 1,
): ...
def get_outputs(self): ...
2 changes: 1 addition & 1 deletion stubs/setuptools/setuptools/command/upload_docs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class upload_docs(upload):
DEFAULT_REPOSITORY: ClassVar[str]
description: ClassVar[str]
user_options: ClassVar[list[tuple[str, str | None, str]]]
boolean_options: ClassVar[list[str]]
boolean_options = upload.boolean_options
def has_sphinx(self): ...
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
Expand Down
13 changes: 10 additions & 3 deletions stubs/setuptools/setuptools/config/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, StrPath
from collections.abc import Callable
from typing import TypeVar

from setuptools.config.setupcfg import AllCommandOptions, ConfigMetadataHandler, ConfigOptionsHandler
from setuptools.dist import Distribution

Fn = TypeVar("Fn", bound=Callable[..., Incomplete]) # noqa: Y001 # Exists at runtime
__all__ = ("parse_configuration", "read_configuration")

def read_configuration(filepath, find_others: bool = False, ignore_option_errors: bool = False): ...
def parse_configuration(distribution, command_options, ignore_option_errors: bool = False): ...
def read_configuration(
filepath: StrPath, find_others: bool = False, ignore_option_errors: bool = False
) -> dict[Incomplete, Incomplete]: ...
def parse_configuration(
distribution: Distribution, command_options: AllCommandOptions, ignore_option_errors: bool = False
) -> tuple[ConfigMetadataHandler, ConfigOptionsHandler]: ...
2 changes: 1 addition & 1 deletion stubs/setuptools/setuptools/config/expand.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _VCo = TypeVar("_VCo", covariant=True)

class StaticModule:
def __init__(self, name: str, spec: ModuleSpec) -> None: ...
def __getattr__(self, attr): ...
def __getattr__(self, attr: str): ...

def glob_relative(patterns: Iterable[str], root_dir: StrPath | None = None) -> list[str]: ...
def read_files(filepaths: StrPath | Iterable[StrPath], root_dir: StrPath | None = None) -> str: ...
Expand Down
Loading