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

Merge overloaded method definitions from typeshed #4506

Merged
merged 2 commits into from
Aug 8, 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
22 changes: 17 additions & 5 deletions setuptools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Extensions to the 'distutils' for large or complex distributions"""

from __future__ import annotations

import functools
import os
import re
import sys
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, TypeVar, overload


sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
# workaround for #4476
Expand All @@ -15,7 +18,7 @@
from distutils.errors import DistutilsOptionError

from . import logging, monkey
from . import version as _version_module
from .version import __version__ as __version__
from .depends import Require
from .discovery import PackageFinder, PEP420PackageFinder
from .dist import Distribution
Expand All @@ -33,11 +36,10 @@
'find_namespace_packages',
]

__version__ = _version_module.__version__
_CommandT = TypeVar("_CommandT", bound="_Command")

bootstrap_install_from = None


find_packages = PackageFinder.find
find_namespace_packages = PEP420PackageFinder.find

Expand Down Expand Up @@ -221,7 +223,17 @@ def ensure_string_list(self, option):
"'%s' must be a list of strings (got %r)" % (option, val)
)

def reinitialize_command(self, command, reinit_subcommands=False, **kw):
@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: ...
def reinitialize_command(
self, command: str | _Command, reinit_subcommands: bool = False, **kw
) -> _Command:
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
vars(cmd).update(kw)
return cmd
Expand Down
Loading