Skip to content

Commit 8c78ed8

Browse files
committed
ANN204 (missing return type for special methods) autofixes
1 parent 566e47d commit 8c78ed8

19 files changed

+34
-32
lines changed

_distutils_hack/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def do_override():
9090

9191

9292
class _TrivialRe:
93-
def __init__(self, *patterns):
93+
def __init__(self, *patterns) -> None:
9494
self._patterns = patterns
9595

9696
def match(self, string):

pkg_resources/tests/test_resources.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def pairwise(iterable):
3232
class Metadata(pkg_resources.EmptyProvider):
3333
"""Mock object to return metadata as if from an on-disk distribution"""
3434

35-
def __init__(self, *pairs):
35+
def __init__(self, *pairs) -> None:
3636
self.metadata = dict(pairs)
3737

3838
def has_metadata(self, name) -> bool:

pkg_resources/tests/test_working_set.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def parse_distributions(s):
5656

5757

5858
class FakeInstaller:
59-
def __init__(self, installable_dists):
59+
def __init__(self, installable_dists) -> None:
6060
self._installable_dists = installable_dists
6161

6262
def __call__(self, req):

setuptools/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MinimalDistribution(distutils.core.Distribution):
6060
fetch_build_eggs interface.
6161
"""
6262

63-
def __init__(self, attrs: Mapping[str, object]):
63+
def __init__(self, attrs: Mapping[str, object]) -> None:
6464
_incl = 'dependency_links', 'setup_requires'
6565
filtered = {k: attrs[k] for k in set(_incl) & set(attrs)}
6666
super().__init__(filtered)
@@ -167,7 +167,7 @@ class Command(_Command):
167167
command_consumes_arguments = False
168168
distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
169169

170-
def __init__(self, dist: Distribution, **kw):
170+
def __init__(self, dist: Distribution, **kw) -> None:
171171
"""
172172
Construct the command for dist, updating
173173
vars(self) with any keyword parameters.

setuptools/build_meta.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373

7474
class SetupRequirementsError(BaseException):
75-
def __init__(self, specifiers):
75+
def __init__(self, specifiers) -> None:
7676
self.specifiers = specifiers
7777

7878

setuptools/command/develop.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class VersionlessRequirement:
185185
'foo'
186186
"""
187187

188-
def __init__(self, dist):
188+
def __init__(self, dist) -> None:
189189
self.__dist = dist
190190

191191
def __getattr__(self, name: str):

setuptools/command/easy_install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ def get_exe_prefixes(exe_filename):
16121612
class PthDistributions(Environment):
16131613
"""A .pth file with Distribution paths in it"""
16141614

1615-
def __init__(self, filename, sitedirs=()):
1615+
def __init__(self, filename, sitedirs=()) -> None:
16161616
self.filename = filename
16171617
self.sitedirs = list(map(normalize_path, sitedirs))
16181618
self.basedir = normalize_path(os.path.dirname(self.filename))

setuptools/command/editable_wheel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def __exit__(
392392

393393

394394
class _StaticPth:
395-
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]):
395+
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None:
396396
self.dist = dist
397397
self.name = name
398398
self.path_entries = path_entries
@@ -436,7 +436,7 @@ def __init__(
436436
name: str,
437437
auxiliary_dir: StrPath,
438438
build_lib: StrPath,
439-
):
439+
) -> None:
440440
self.auxiliary_dir = Path(auxiliary_dir)
441441
self.build_lib = Path(build_lib).resolve()
442442
self._file = dist.get_command_obj("build_py").copy_file
@@ -496,7 +496,7 @@ def __exit__(
496496

497497

498498
class _TopLevelFinder:
499-
def __init__(self, dist: Distribution, name: str):
499+
def __init__(self, dist: Distribution, name: str) -> None:
500500
self.dist = dist
501501
self.name = name
502502

setuptools/command/egg_info.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ def find_sources(self) -> None:
324324
class FileList(_FileList):
325325
# Implementations of the various MANIFEST.in commands
326326

327-
def __init__(self, warn=None, debug_print=None, ignore_egg_info_dir: bool = False):
327+
def __init__(
328+
self, warn=None, debug_print=None, ignore_egg_info_dir: bool = False
329+
) -> None:
328330
super().__init__(warn, debug_print)
329331
self.ignore_egg_info_dir = ignore_egg_info_dir
330332

setuptools/config/expand.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
class StaticModule:
5353
"""Proxy to a module object that avoids executing arbitrary code."""
5454

55-
def __init__(self, name: str, spec: ModuleSpec):
55+
def __init__(self, name: str, spec: ModuleSpec) -> None:
5656
module = ast.parse(pathlib.Path(spec.origin).read_bytes()) # type: ignore[arg-type] # Let it raise an error on None
5757
vars(self).update(locals())
5858
del self.self
@@ -383,7 +383,7 @@ class EnsurePackagesDiscovered:
383383
and those might not have been processed yet.
384384
"""
385385

386-
def __init__(self, distribution: Distribution):
386+
def __init__(self, distribution: Distribution) -> None:
387387
self._dist = distribution
388388
self._called = False
389389

@@ -430,7 +430,7 @@ class LazyMappingProxy(Mapping[_K, _V_co]):
430430
'other value'
431431
"""
432432

433-
def __init__(self, obtain_mapping_value: Callable[[], Mapping[_K, _V_co]]):
433+
def __init__(self, obtain_mapping_value: Callable[[], Mapping[_K, _V_co]]) -> None:
434434
self._obtain = obtain_mapping_value
435435
self._value: Mapping[_K, _V_co] | None = None
436436

setuptools/config/pyprojecttoml.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def __init__(
176176
root_dir: StrPath | None = None,
177177
ignore_option_errors: bool = False,
178178
dist: Distribution | None = None,
179-
):
179+
) -> None:
180180
self.config = config
181181
self.root_dir = root_dir or os.getcwd()
182182
self.project_cfg = config.get("project", {})
@@ -413,7 +413,7 @@ def _ignore_errors(ignore_option_errors: bool):
413413
class _EnsurePackagesDiscovered(_expand.EnsurePackagesDiscovered):
414414
def __init__(
415415
self, distribution: Distribution, project_cfg: dict, setuptools_cfg: dict
416-
):
416+
) -> None:
417417
super().__init__(distribution)
418418
self._project_cfg = project_cfg
419419
self._setuptools_cfg = setuptools_cfg

setuptools/config/setupcfg.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def __init__(
247247
options: AllCommandOptions,
248248
ignore_option_errors,
249249
ensure_discovered: expand.EnsurePackagesDiscovered,
250-
):
250+
) -> None:
251251
self.ignore_option_errors = ignore_option_errors
252252
self.target_obj: Target = target_obj
253253
self.sections = dict(self._section_options(options))
@@ -540,7 +540,7 @@ def __init__(
540540
ensure_discovered: expand.EnsurePackagesDiscovered,
541541
package_dir: dict | None = None,
542542
root_dir: StrPath | None = os.curdir,
543-
):
543+
) -> None:
544544
super().__init__(target_obj, options, ignore_option_errors, ensure_discovered)
545545
self.package_dir = package_dir
546546
self.root_dir = root_dir
@@ -602,7 +602,7 @@ def __init__(
602602
options: AllCommandOptions,
603603
ignore_option_errors: bool,
604604
ensure_discovered: expand.EnsurePackagesDiscovered,
605-
):
605+
) -> None:
606606
super().__init__(target_obj, options, ignore_option_errors, ensure_discovered)
607607
self.root_dir = target_obj.src_root
608608
self.package_dir: dict[str, str] = {} # To be filled by `find_packages`

setuptools/depends.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(
2828
homepage: str = '',
2929
attribute=None,
3030
format=None,
31-
):
31+
) -> None:
3232
if format is None and requested_version is not None:
3333
format = Version
3434

setuptools/discovery.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class _Filter:
7171
the input matches at least one of the patterns.
7272
"""
7373

74-
def __init__(self, *patterns: str):
74+
def __init__(self, *patterns: str) -> None:
7575
self._patterns = dict.fromkeys(patterns)
7676

7777
def __call__(self, item: str) -> bool:
@@ -300,7 +300,7 @@ class ConfigDiscovery:
300300
(from other metadata/options, the file system or conventions)
301301
"""
302302

303-
def __init__(self, distribution: Distribution):
303+
def __init__(self, distribution: Distribution) -> None:
304304
self.dist = distribution
305305
self._called = False
306306
self._disabled = False

setuptools/extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __init__(
147147
*args,
148148
py_limited_api: bool = False,
149149
**kw,
150-
):
150+
) -> None:
151151
# The *args is needed for compatibility as calls may use positional
152152
# arguments. py_limited_api may be set only via keyword.
153153
self.py_limited_api = py_limited_api

setuptools/msvc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PlatformInfo:
5050

5151
current_cpu = environ.get('processor_architecture', '').lower()
5252

53-
def __init__(self, arch):
53+
def __init__(self, arch) -> None:
5454
self.arch = arch.lower().replace('x64', 'amd64')
5555

5656
@property
@@ -176,7 +176,7 @@ class RegistryInfo:
176176
winreg.HKEY_CLASSES_ROOT,
177177
)
178178

179-
def __init__(self, platform_info):
179+
def __init__(self, platform_info) -> None:
180180
self.pi = platform_info
181181

182182
@property
@@ -366,7 +366,7 @@ class SystemInfo:
366366
ProgramFiles = environ.get('ProgramFiles', '')
367367
ProgramFilesx86 = environ.get('ProgramFiles(x86)', ProgramFiles)
368368

369-
def __init__(self, registry_info, vc_ver=None):
369+
def __init__(self, registry_info, vc_ver=None) -> None:
370370
self.ri = registry_info
371371
self.pi = self.ri.pi
372372

@@ -911,7 +911,7 @@ class EnvironmentInfo:
911911
# Variables and properties in this class use originals CamelCase variables
912912
# names from Microsoft source files for more easy comparison.
913913

914-
def __init__(self, arch, vc_ver=None, vc_min_ver=0):
914+
def __init__(self, arch, vc_ver=None, vc_min_ver=0) -> None:
915915
self.pi = PlatformInfo(arch)
916916
self.ri = RegistryInfo(self.pi)
917917
self.si = SystemInfo(self.ri, vc_ver)

setuptools/package_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class HashChecker(ContentChecker):
270270
r'(?P<expected>[a-f0-9]+)'
271271
)
272272

273-
def __init__(self, hash_name, expected):
273+
def __init__(self, hash_name, expected) -> None:
274274
self.hash_name = hash_name
275275
self.hash = hashlib.new(hash_name)
276276
self.expected = expected

setuptools/sandbox.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class AbstractSandbox:
279279

280280
_active = False
281281

282-
def __init__(self):
282+
def __init__(self) -> None:
283283
self._attrs = [
284284
name
285285
for name in dir(_os)
@@ -442,7 +442,7 @@ class DirectorySandbox(AbstractSandbox):
442442
_exception_patterns: list[str | re.Pattern] = []
443443
"exempt writing to paths that match the pattern"
444444

445-
def __init__(self, sandbox, exceptions=_EXCEPTIONS):
445+
def __init__(self, sandbox, exceptions=_EXCEPTIONS) -> None:
446446
self._sandbox = os.path.normcase(os.path.realpath(sandbox))
447447
self._prefix = os.path.join(self._sandbox, '')
448448
self._exceptions = [

setuptools/wheel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def disable_info_traces():
7676

7777

7878
class Wheel:
79-
def __init__(self, filename):
79+
def __init__(self, filename) -> None:
8080
match = WHEEL_NAME(os.path.basename(filename))
8181
if match is None:
8282
raise ValueError('invalid wheel name: %r' % filename)

0 commit comments

Comments
 (0)