-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Re-enable ANN2 for setuptools #4709
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
from setuptools import Command | ||
from setuptools.extension import Library | ||
|
||
from .._path import ensure_directory | ||
from .._path import StrPathT, ensure_directory | ||
|
||
from distutils import log | ||
from distutils.dir_util import mkpath, remove_tree | ||
|
@@ -440,13 +440,13 @@ def can_scan(): | |
|
||
|
||
def make_zipfile( | ||
zip_filename, | ||
zip_filename: StrPathT, | ||
base_dir, | ||
verbose: bool = False, | ||
dry_run: bool = False, | ||
compress=True, | ||
mode: _ZipFileMode = 'w', | ||
): | ||
) -> StrPathT: | ||
"""Create a zip file from all the files under 'base_dir'. The output | ||
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" | ||
Python module (if available) or the InfoZIP "zip" utility (if installed | ||
|
@@ -455,7 +455,7 @@ def make_zipfile( | |
""" | ||
import zipfile | ||
|
||
mkpath(os.path.dirname(zip_filename), dry_run=dry_run) | ||
mkpath(os.path.dirname(zip_filename), dry_run=dry_run) # type: ignore[arg-type] # python/mypy#18075 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ref: python/mypy#18075 |
||
log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) | ||
|
||
def visit(z, dirname, names): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,7 @@ | |
|
||
from more_itertools import unique_everseen | ||
|
||
from setuptools._path import StrPath | ||
|
||
from .._path import StrPath, StrPathT | ||
from ..dist import Distribution | ||
from ..warnings import SetuptoolsDeprecationWarning | ||
|
||
|
@@ -50,20 +49,20 @@ def finalize_options(self): | |
del self.__dict__['data_files'] | ||
self.__updated_files = [] | ||
|
||
def copy_file( # type: ignore[override] # No overload, str support only | ||
def copy_file( # type: ignore[override] # No overload, no bytes support | ||
self, | ||
infile: StrPath, | ||
outfile: StrPath, | ||
outfile: StrPathT, | ||
preserve_mode: bool = True, | ||
preserve_times: bool = True, | ||
link: str | None = None, | ||
level: object = 1, | ||
): | ||
) -> tuple[StrPathT | str, bool]: | ||
# Overwrite base class to allow using links | ||
if link: | ||
infile = str(Path(infile).resolve()) | ||
outfile = str(Path(outfile).resolve()) | ||
return super().copy_file( | ||
outfile = str(Path(outfile).resolve()) # type: ignore[assignment] # Re-assigning a str when outfile is StrPath is ok | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may or may not also be related to python/mypy#18075 |
||
return super().copy_file( # pyright: ignore[reportReturnType] # pypa/distutils#309 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ref.: pypa/distutils#309 |
||
infile, outfile, preserve_mode, preserve_times, link, level | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,13 @@ | |
from packaging.specifiers import InvalidSpecifier, SpecifierSet | ||
from packaging.version import Version | ||
|
||
from setuptools._path import StrPath | ||
|
||
from . import ( | ||
_entry_points, | ||
_reqs, | ||
command as _, # noqa: F401 # imported for side-effects | ||
) | ||
from ._importlib import metadata | ||
from ._path import StrPath | ||
from ._reqs import _StrOrIter | ||
from .config import pyprojecttoml, setupcfg | ||
from .discovery import ConfigDiscovery | ||
|
@@ -52,6 +51,9 @@ | |
if TYPE_CHECKING: | ||
from typing_extensions import TypeAlias | ||
|
||
from pkg_resources import Distribution as _pkg_resources_Distribution | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is good this is inside a Ideally we want to avoid importing It is only acceptable to "lazily" import |
||
|
||
|
||
__all__ = ['Distribution'] | ||
|
||
_sequence = tuple, list | ||
|
@@ -518,7 +520,7 @@ def _parse_config_files(self, filenames=None): # noqa: C901 | |
except ValueError as e: | ||
raise DistutilsOptionError(e) from e | ||
|
||
def warn_dash_deprecation(self, opt: str, section: str): | ||
def warn_dash_deprecation(self, opt: str, section: str) -> str: | ||
if section in ( | ||
'options.extras_require', | ||
'options.data_files', | ||
|
@@ -560,7 +562,7 @@ def _setuptools_commands(self): | |
# during bootstrapping, distribution doesn't exist | ||
return [] | ||
|
||
def make_option_lowercase(self, opt: str, section: str): | ||
def make_option_lowercase(self, opt: str, section: str) -> str: | ||
if section != 'metadata' or opt.islower(): | ||
return opt | ||
|
||
|
@@ -640,7 +642,7 @@ def parse_config_files( | |
self, | ||
filenames: Iterable[StrPath] | None = None, | ||
ignore_option_errors: bool = False, | ||
): | ||
) -> None: | ||
"""Parses configuration files from various levels | ||
and loads configuration. | ||
""" | ||
|
@@ -657,7 +659,9 @@ def parse_config_files( | |
self._finalize_requires() | ||
self._finalize_license_files() | ||
|
||
def fetch_build_eggs(self, requires: _StrOrIter): | ||
def fetch_build_eggs( | ||
self, requires: _StrOrIter | ||
) -> list[_pkg_resources_Distribution]: | ||
"""Resolve pre-setup requirements""" | ||
from .installer import _fetch_build_eggs | ||
|
||
|
@@ -728,7 +732,7 @@ def fetch_build_egg(self, req): | |
|
||
return fetch_build_egg(self, req) | ||
|
||
def get_command_class(self, command: str): | ||
def get_command_class(self, command: str) -> type[distutils.cmd.Command]: # type: ignore[override] # Not doing complex overrides yet | ||
"""Pluggable version of get_command_class()""" | ||
if command in self.cmdclass: | ||
return self.cmdclass[command] | ||
|
@@ -782,7 +786,7 @@ def include(self, **attrs): | |
else: | ||
self._include_misc(k, v) | ||
|
||
def exclude_package(self, package: str): | ||
def exclude_package(self, package: str) -> None: | ||
"""Remove packages, modules, and extensions in named package""" | ||
|
||
pfx = package + '.' | ||
|
@@ -803,7 +807,7 @@ def exclude_package(self, package: str): | |
if p.name != package and not p.name.startswith(pfx) | ||
] | ||
|
||
def has_contents_for(self, package: str): | ||
def has_contents_for(self, package: str) -> bool: | ||
"""Return true if 'exclude_package(package)' would do something""" | ||
|
||
pfx = package + '.' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref.: pypa/distutils#307