Skip to content

Commit dc2050e

Browse files
authored
setuptools ANN201 autofixes for fully untyped functions (#4711)
2 parents 584dfa8 + 04b515e commit dc2050e

32 files changed

+151
-150
lines changed

_distutils_hack/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import sys
44

55
report_url = (
6-
"https://github.com/pypa/setuptools/issues/new?"
7-
"template=distutils-deprecation.yml"
6+
"https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml"
87
)
98

109

setuptools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def _ensure_stringlike(self, option, what, default=None):
186186
)
187187
return val
188188

189-
def ensure_string_list(self, option: str):
189+
def ensure_string_list(self, option: str) -> None:
190190
r"""Ensure that 'option' is a list of strings. If 'option' is
191191
currently a string, we split it either on /,\s*/ or /\s+/, so
192192
"foo bar baz", "foo,bar,baz", and "foo, bar baz" all become

setuptools/archive_util.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def default_filter(src, dst):
3131
return dst
3232

3333

34-
def unpack_archive(filename, extract_dir, progress_filter=default_filter, drivers=None):
34+
def unpack_archive(
35+
filename, extract_dir, progress_filter=default_filter, drivers=None
36+
) -> None:
3537
"""Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``
3638
3739
`progress_filter` is a function taking two arguments: a source path
@@ -63,7 +65,7 @@ def unpack_archive(filename, extract_dir, progress_filter=default_filter, driver
6365
raise UnrecognizedFormat("Not a recognized archive type: %s" % filename)
6466

6567

66-
def unpack_directory(filename, extract_dir, progress_filter=default_filter):
68+
def unpack_directory(filename, extract_dir, progress_filter=default_filter) -> None:
6769
""" "Unpack" a directory, using the same interface as for archives
6870
6971
Raises ``UnrecognizedFormat`` if `filename` is not a directory
@@ -90,7 +92,7 @@ def unpack_directory(filename, extract_dir, progress_filter=default_filter):
9092
shutil.copystat(f, target)
9193

9294

93-
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
95+
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter) -> None:
9496
"""Unpack zip `filename` to `extract_dir`
9597
9698
Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
@@ -185,7 +187,7 @@ def _iter_open_tar(tar_obj, extract_dir, progress_filter):
185187
yield member, final_dst
186188

187189

188-
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
190+
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter) -> bool:
189191
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
190192
191193
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined

setuptools/command/alias.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def initialize_options(self):
3030
self.args = None
3131
self.remove = None
3232

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

40-
def run(self):
40+
def run(self) -> None:
4141
aliases = self.distribution.get_option_dict('aliases')
4242

4343
if not self.args:

setuptools/command/bdist_egg.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def sorted_walk(dir):
5050
yield base, dirs, files
5151

5252

53-
def write_stub(resource, pyfile):
53+
def write_stub(resource, pyfile) -> None:
5454
_stub_template = textwrap.dedent(
5555
"""
5656
def __bootstrap__():
@@ -101,7 +101,7 @@ def initialize_options(self):
101101
self.egg_output = None
102102
self.exclude_source_files = None
103103

104-
def finalize_options(self):
104+
def finalize_options(self) -> None:
105105
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
106106
self.egg_info = ei_cmd.egg_info
107107

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

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

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

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

280-
def gen_header(self):
280+
def gen_header(self) -> str:
281281
return 'w'
282282

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

355355

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

423423

424-
def can_scan():
424+
def can_scan() -> bool:
425425
if not sys.platform.startswith('java') and sys.platform != 'cli':
426426
# CPython, PyPy, etc.
427427
return True

setuptools/command/bdist_rpm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class bdist_rpm(orig.bdist_rpm):
1515

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

18-
def run(self):
18+
def run(self) -> None:
1919
SetuptoolsDeprecationWarning.emit(
2020
"Deprecated command",
2121
"""

setuptools/command/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def finalize_options(self):
8585
...
8686
"""
8787

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

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

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

setuptools/command/build_clib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class build_clib(orig.build_clib):
2424

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

27-
def build_libraries(self, libraries):
27+
def build_libraries(self, libraries) -> None:
2828
for lib_name, build_info in libraries:
2929
sources = build_info.get('sources')
3030
if sources is None or not isinstance(sources, (list, tuple)):

setuptools/command/build_ext.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _get_inplace_equivalent(self, build_py, ext: Extension) -> tuple[str, str]:
110110
regular_file = os.path.join(self.build_lib, filename)
111111
return (inplace_file, regular_file)
112112

113-
def copy_extensions_to_source(self):
113+
def copy_extensions_to_source(self) -> None:
114114
build_py = self.get_finalized_command('build_py')
115115
for ext in self.extensions:
116116
inplace_file, regular_file = self._get_inplace_equivalent(build_py, ext)
@@ -191,7 +191,7 @@ def initialize_options(self):
191191
self.ext_map = {}
192192
self.editable_mode = False
193193

194-
def finalize_options(self):
194+
def finalize_options(self) -> None:
195195
_build_ext.finalize_options(self)
196196
self.extensions = self.extensions or []
197197
self.check_extensions_list(self.extensions)
@@ -254,7 +254,7 @@ def get_export_symbols(self, ext):
254254
return ext.export_symbols
255255
return _build_ext.get_export_symbols(self, ext)
256256

257-
def build_extension(self, ext):
257+
def build_extension(self, ext) -> None:
258258
ext._convert_pyx_sources_to_lang()
259259
_compiler = self.compiler
260260
try:
@@ -344,7 +344,7 @@ def __get_output_extensions(self):
344344
if self.get_finalized_command('build_py').optimize:
345345
yield '.pyo'
346346

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

@@ -415,7 +415,7 @@ def link_shared_object(
415415
extra_postargs=None,
416416
build_temp=None,
417417
target_lang=None,
418-
):
418+
) -> None:
419419
self.link(
420420
self.SHARED_LIBRARY,
421421
objects,
@@ -450,7 +450,7 @@ def link_shared_object(
450450
extra_postargs=None,
451451
build_temp=None,
452452
target_lang=None,
453-
):
453+
) -> None:
454454
# XXX we need to either disallow these attrs on Library instances,
455455
# or warn/abort here if set, or something...
456456
# libraries=None, library_dirs=None, runtime_library_dirs=None,

setuptools/command/build_py.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
_IMPLICIT_DATA_FILES = ('*.pyi', 'py.typed')
2525

2626

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

3030

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

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

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

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

245245
def check_package(self, package, package_dir):

0 commit comments

Comments
 (0)