-
-
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
Runtime typing fixes for typeshed return type merge #4753
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 |
---|---|---|
|
@@ -39,15 +39,14 @@ class build_py(orig.build_py): | |
|
||
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution | ||
editable_mode: bool = False | ||
existing_egg_info_dir: str | None = None #: Private API, internal use only. | ||
existing_egg_info_dir: StrPath | None = None #: Private API, internal use only. | ||
|
||
def finalize_options(self): | ||
orig.build_py.finalize_options(self) | ||
self.package_data = self.distribution.package_data | ||
self.exclude_package_data = self.distribution.exclude_package_data or {} | ||
if 'data_files' in self.__dict__: | ||
del self.__dict__['data_files'] | ||
self.__updated_files = [] | ||
|
||
def copy_file( # type: ignore[override] # No overload, no bytes support | ||
self, | ||
|
@@ -89,12 +88,6 @@ def __getattr__(self, attr: str): | |
return self.data_files | ||
return orig.build_py.__getattr__(self, attr) | ||
|
||
def build_module(self, module, module_file, package): | ||
outfile, copied = orig.build_py.build_module(self, module, module_file, package) | ||
if copied: | ||
self.__updated_files.append(outfile) | ||
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. Looks like 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. I see, apparently it was introduced for the In this case, does it make sense to keep this method? (It will only call 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. You're right! I didn't even notice that. I'd remove the method entirely at this point. 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. I agree, it is better to remove it. |
||
return outfile, copied | ||
|
||
def _get_data_files(self): | ||
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples""" | ||
self.analyze_manifest() | ||
|
@@ -178,17 +171,17 @@ def build_package_data(self) -> None: | |
_outf, _copied = self.copy_file(srcfile, target) | ||
make_writable(target) | ||
|
||
def analyze_manifest(self): | ||
self.manifest_files = mf = {} | ||
def analyze_manifest(self) -> None: | ||
self.manifest_files: dict[str, list[str]] = {} | ||
if not self.distribution.include_package_data: | ||
return | ||
src_dirs = {} | ||
src_dirs: dict[str, str] = {} | ||
for package in self.packages or (): | ||
# Locate package source directory | ||
src_dirs[assert_relative(self.get_package_dir(package))] = package | ||
|
||
if ( | ||
getattr(self, 'existing_egg_info_dir', None) | ||
self.existing_egg_info_dir | ||
and Path(self.existing_egg_info_dir, "SOURCES.txt").exists() | ||
): | ||
egg_info_dir = self.existing_egg_info_dir | ||
|
@@ -217,9 +210,11 @@ def analyze_manifest(self): | |
importable = check.importable_subpackage(src_dirs[d], f) | ||
if importable: | ||
check.warn(importable) | ||
mf.setdefault(src_dirs[d], []).append(path) | ||
self.manifest_files.setdefault(src_dirs[d], []).append(path) | ||
|
||
def _filter_build_files(self, files: Iterable[str], egg_info: str) -> Iterator[str]: | ||
def _filter_build_files( | ||
self, files: Iterable[str], egg_info: StrPath | ||
) -> Iterator[str]: | ||
""" | ||
``build_meta`` may try to create egg_info outside of the project directory, | ||
and this can be problematic for certain plugins (reported in issue #3500). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import sys | ||
import unicodedata | ||
from configparser import ConfigParser | ||
from configparser import RawConfigParser | ||
|
||
from .compat import py39 | ||
from .warnings import SetuptoolsDeprecationWarning | ||
|
@@ -65,10 +65,10 @@ def _read_utf8_with_fallback(file: str, fallback_encoding=py39.LOCALE_ENCODING) | |
|
||
|
||
def _cfg_read_utf8_with_fallback( | ||
cfg: ConfigParser, file: str, fallback_encoding=py39.LOCALE_ENCODING | ||
cfg: RawConfigParser, file: str, fallback_encoding=py39.LOCALE_ENCODING | ||
) -> None: | ||
"""Same idea as :func:`_read_utf8_with_fallback`, but for the | ||
:meth:`ConfigParser.read` method. | ||
:meth:`RawConfigParser.read` method. | ||
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 also allows any subclass, right? 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. Correct. Setuptools passes a |
||
|
||
This method may call ``cfg.clear()``. | ||
""" | ||
|
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.
data_dir
is always set infinalize_options
, so if I understand correctly this value doesn't matter and it'll always be a string.