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 ANN201 autofixes for fully untyped functions #4711

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import sys

report_url = (
"https://github.com/pypa/setuptools/issues/new?"
"template=distutils-deprecation.yml"
"https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml"
)


Expand Down
2 changes: 1 addition & 1 deletion setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _ensure_stringlike(self, option, what, default=None):
)
return val

def ensure_string_list(self, option: str):
def ensure_string_list(self, option: str) -> None:
r"""Ensure that 'option' is a list of strings. If 'option' is
currently a string, we split it either on /,\s*/ or /\s+/, so
"foo bar baz", "foo,bar,baz", and "foo, bar baz" all become
Expand Down
10 changes: 6 additions & 4 deletions setuptools/archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def default_filter(src, dst):
return dst


def unpack_archive(filename, extract_dir, progress_filter=default_filter, drivers=None):
def unpack_archive(
filename, extract_dir, progress_filter=default_filter, drivers=None
) -> None:
"""Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``

`progress_filter` is a function taking two arguments: a source path
Expand Down Expand Up @@ -63,7 +65,7 @@ def unpack_archive(filename, extract_dir, progress_filter=default_filter, driver
raise UnrecognizedFormat("Not a recognized archive type: %s" % filename)


def unpack_directory(filename, extract_dir, progress_filter=default_filter):
def unpack_directory(filename, extract_dir, progress_filter=default_filter) -> None:
""" "Unpack" a directory, using the same interface as for archives

Raises ``UnrecognizedFormat`` if `filename` is not a directory
Expand All @@ -90,7 +92,7 @@ def unpack_directory(filename, extract_dir, progress_filter=default_filter):
shutil.copystat(f, target)


def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter) -> None:
"""Unpack zip `filename` to `extract_dir`

Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
Expand Down Expand Up @@ -185,7 +187,7 @@ def _iter_open_tar(tar_obj, extract_dir, progress_filter):
yield member, final_dst


def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter) -> bool:
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`

Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
Expand Down
4 changes: 2 additions & 2 deletions setuptools/command/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def initialize_options(self):
self.args = None
self.remove = None

def finalize_options(self):
def finalize_options(self) -> None:
option_base.finalize_options(self)
if self.remove and len(self.args) != 1:
raise DistutilsOptionError(
"Must specify exactly one argument (the alias name) when using --remove"
)

def run(self):
def run(self) -> None:
aliases = self.distribution.get_option_dict('aliases')

if not self.args:
Expand Down
14 changes: 7 additions & 7 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def sorted_walk(dir):
yield base, dirs, files


def write_stub(resource, pyfile):
def write_stub(resource, pyfile) -> None:
_stub_template = textwrap.dedent(
"""
def __bootstrap__():
Expand Down Expand Up @@ -101,7 +101,7 @@ def initialize_options(self):
self.egg_output = None
self.exclude_source_files = None

def finalize_options(self):
def finalize_options(self) -> None:
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
self.egg_info = ei_cmd.egg_info

Expand All @@ -125,7 +125,7 @@ def finalize_options(self):

self.egg_output = os.path.join(self.dist_dir, basename + '.egg')

def do_install_data(self):
def do_install_data(self) -> None:
# Hack for packages that install data to install's --install-lib
self.get_finalized_command('install').install_lib = self.bdist_dir

Expand Down Expand Up @@ -277,10 +277,10 @@ def zip_safe(self):
log.warn("zip_safe flag not set; analyzing archive contents...")
return analyze_egg(self.bdist_dir, self.stubs)

def gen_header(self):
def gen_header(self) -> str:
return 'w'

def copy_metadata_to(self, target_dir):
def copy_metadata_to(self, target_dir) -> None:
"Copy metadata (egg info) to the target_dir"
# normalize the path (so that a forward-slash in egg_info will
# match using startswith below)
Expand Down Expand Up @@ -353,7 +353,7 @@ def analyze_egg(egg_dir, stubs):
return safe


def write_safety_flag(egg_dir, safe):
def write_safety_flag(egg_dir, safe) -> None:
# Write or remove zip safety flag file(s)
for flag, fn in safety_flags.items():
fn = os.path.join(egg_dir, fn)
Expand Down Expand Up @@ -421,7 +421,7 @@ def iter_symbols(code):
yield from iter_symbols(const)


def can_scan():
def can_scan() -> bool:
if not sys.platform.startswith('java') and sys.platform != 'cli':
# CPython, PyPy, etc.
return True
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class bdist_rpm(orig.bdist_rpm):

distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution

def run(self):
def run(self) -> None:
SetuptoolsDeprecationWarning.emit(
"Deprecated command",
"""
Expand Down
6 changes: 3 additions & 3 deletions setuptools/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def finalize_options(self):
...
"""

def initialize_options(self):
def initialize_options(self) -> None:
"""(Required by the original :class:`setuptools.Command` interface)"""
...

def finalize_options(self):
def finalize_options(self) -> None:
"""(Required by the original :class:`setuptools.Command` interface)"""
...

def run(self):
def run(self) -> None:
"""(Required by the original :class:`setuptools.Command` interface)"""
...

Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class build_clib(orig.build_clib):

distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution

def build_libraries(self, libraries):
def build_libraries(self, libraries) -> None:
for lib_name, build_info in libraries:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
Expand Down
12 changes: 6 additions & 6 deletions setuptools/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _get_inplace_equivalent(self, build_py, ext: Extension) -> tuple[str, str]:
regular_file = os.path.join(self.build_lib, filename)
return (inplace_file, regular_file)

def copy_extensions_to_source(self):
def copy_extensions_to_source(self) -> None:
build_py = self.get_finalized_command('build_py')
for ext in self.extensions:
inplace_file, regular_file = self._get_inplace_equivalent(build_py, ext)
Expand Down Expand Up @@ -191,7 +191,7 @@ def initialize_options(self):
self.ext_map = {}
self.editable_mode = False

def finalize_options(self):
def finalize_options(self) -> None:
_build_ext.finalize_options(self)
self.extensions = self.extensions or []
self.check_extensions_list(self.extensions)
Expand Down Expand Up @@ -254,7 +254,7 @@ def get_export_symbols(self, ext):
return ext.export_symbols
return _build_ext.get_export_symbols(self, ext)

def build_extension(self, ext):
def build_extension(self, ext) -> None:
ext._convert_pyx_sources_to_lang()
_compiler = self.compiler
try:
Expand Down Expand Up @@ -344,7 +344,7 @@ def __get_output_extensions(self):
if self.get_finalized_command('build_py').optimize:
yield '.pyo'

def write_stub(self, output_dir, ext, compile=False):
def write_stub(self, output_dir, ext, compile=False) -> None:
stub_file = os.path.join(output_dir, *ext._full_name.split('.')) + '.py'
self._write_stub_file(stub_file, ext, compile)

Expand Down Expand Up @@ -415,7 +415,7 @@ def link_shared_object(
extra_postargs=None,
build_temp=None,
target_lang=None,
):
) -> None:
self.link(
self.SHARED_LIBRARY,
objects,
Expand Down Expand Up @@ -450,7 +450,7 @@ def link_shared_object(
extra_postargs=None,
build_temp=None,
target_lang=None,
):
) -> None:
# XXX we need to either disallow these attrs on Library instances,
# or warn/abort here if set, or something...
# libraries=None, library_dirs=None, runtime_library_dirs=None,
Expand Down
8 changes: 4 additions & 4 deletions setuptools/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
_IMPLICIT_DATA_FILES = ('*.pyi', 'py.typed')


def make_writable(target):
def make_writable(target) -> None:
os.chmod(target, os.stat(target).st_mode | stat.S_IWRITE)


Expand Down Expand Up @@ -67,7 +67,7 @@ def copy_file( # type: ignore[override] # No overload, str support only
infile, outfile, preserve_mode, preserve_times, link, level
)

def run(self):
def run(self) -> None:
"""Build modules, packages, and copy data files to build directory"""
if not (self.py_modules or self.packages) or self.editable_mode:
return
Expand Down Expand Up @@ -172,7 +172,7 @@ def _get_package_data_output_mapping(self) -> Iterator[tuple[str, str]]:
srcfile = os.path.join(src_dir, filename)
yield (target, srcfile)

def build_package_data(self):
def build_package_data(self) -> None:
"""Copy data files into build directory"""
for target, srcfile in self._get_package_data_output_mapping():
self.mkpath(os.path.dirname(target))
Expand Down Expand Up @@ -239,7 +239,7 @@ def _filter_build_files(self, files: Iterable[str], egg_info: str) -> Iterator[s
if not os.path.isabs(file) or all(d not in norm_path for d in norm_dirs):
yield file

def get_data_files(self):
def get_data_files(self) -> None:
pass # Lazily compute data files in _get_data_files() function.

def check_package(self, package, package_dir):
Expand Down
6 changes: 3 additions & 3 deletions setuptools/command/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def initialize_options(self):
self.setup_path = None
self.always_copy_from = '.' # always copy eggs installed in curdir

def finalize_options(self):
def finalize_options(self) -> None:
import pkg_resources

ei = self.get_finalized_command("egg_info")
Expand Down Expand Up @@ -104,7 +104,7 @@ def _resolve_setup_path(egg_base, install_dir, egg_path):
)
return path_to_setup

def install_for_development(self):
def install_for_development(self) -> None:
self.run_command('egg_info')

# Build extensions in-place
Expand All @@ -126,7 +126,7 @@ def install_for_development(self):
# and handling requirements
self.process_distribution(None, self.dist, not self.no_deps)

def uninstall_link(self):
def uninstall_link(self) -> None:
if os.path.exists(self.egg_link):
log.info("Removing %s (link to %s)", self.egg_link, self.egg_base)

Expand Down
4 changes: 2 additions & 2 deletions setuptools/command/dist_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initialize_options(self):
self.tag_build = None
self.keep_egg_info = False

def finalize_options(self):
def finalize_options(self) -> None:
dist = self.distribution
project_dir = dist.src_root or os.curdir
self.output_dir = Path(self.output_dir or project_dir)
Expand Down Expand Up @@ -88,7 +88,7 @@ def _maybe_bkp_dir(self, dir_path: str, requires_bkp: bool):
else:
yield

def run(self):
def run(self) -> None:
self.output_dir.mkdir(parents=True, exist_ok=True)
self.egg_info.run()
egg_info_dir = self.egg_info.egg_info
Expand Down
Loading
Loading