Skip to content

Commit

Permalink
ANN204 (missing return type for special methods) autofixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Nov 6, 2024
1 parent 566e47d commit 8343991
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def do_override():


class _TrivialRe:
def __init__(self, *patterns):
def __init__(self, *patterns) -> None:
self._patterns = patterns

def match(self, string):
Expand Down
2 changes: 1 addition & 1 deletion pkg_resources/tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def pairwise(iterable):
class Metadata(pkg_resources.EmptyProvider):
"""Mock object to return metadata as if from an on-disk distribution"""

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

def has_metadata(self, name) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion pkg_resources/tests/test_working_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse_distributions(s):


class FakeInstaller:
def __init__(self, installable_dists):
def __init__(self, installable_dists) -> None:
self._installable_dists = installable_dists

def __call__(self, req):
Expand Down
4 changes: 2 additions & 2 deletions setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MinimalDistribution(distutils.core.Distribution):
fetch_build_eggs interface.
"""

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

def __init__(self, dist: Distribution, **kw):
def __init__(self, dist: Distribution, **kw) -> None:
"""
Construct the command for dist, updating
vars(self) with any keyword parameters.
Expand Down
2 changes: 1 addition & 1 deletion setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@


class SetupRequirementsError(BaseException):
def __init__(self, specifiers):
def __init__(self, specifiers) -> None:
self.specifiers = specifiers


Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class VersionlessRequirement:
'foo'
"""

def __init__(self, dist):
def __init__(self, dist) -> None:
self.__dist = dist

def __getattr__(self, name: str):
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ def get_exe_prefixes(exe_filename):
class PthDistributions(Environment):
"""A .pth file with Distribution paths in it"""

def __init__(self, filename, sitedirs=()):
def __init__(self, filename, sitedirs=()) -> None:
self.filename = filename
self.sitedirs = list(map(normalize_path, sitedirs))
self.basedir = normalize_path(os.path.dirname(self.filename))
Expand Down
6 changes: 3 additions & 3 deletions setuptools/command/editable_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def __exit__(


class _StaticPth:
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]):
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None:
self.dist = dist
self.name = name
self.path_entries = path_entries
Expand Down Expand Up @@ -436,7 +436,7 @@ def __init__(
name: str,
auxiliary_dir: StrPath,
build_lib: StrPath,
):
) -> None:
self.auxiliary_dir = Path(auxiliary_dir)
self.build_lib = Path(build_lib).resolve()
self._file = dist.get_command_obj("build_py").copy_file
Expand Down Expand Up @@ -496,7 +496,7 @@ def __exit__(


class _TopLevelFinder:
def __init__(self, dist: Distribution, name: str):
def __init__(self, dist: Distribution, name: str) -> None:
self.dist = dist
self.name = name

Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def find_sources(self) -> None:
class FileList(_FileList):
# Implementations of the various MANIFEST.in commands

def __init__(self, warn=None, debug_print=None, ignore_egg_info_dir: bool = False):
def __init__(self, warn=None, debug_print=None, ignore_egg_info_dir: bool = False) -> None:
super().__init__(warn, debug_print)
self.ignore_egg_info_dir = ignore_egg_info_dir

Expand Down
6 changes: 3 additions & 3 deletions setuptools/config/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
class StaticModule:
"""Proxy to a module object that avoids executing arbitrary code."""

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

def __init__(self, distribution: Distribution):
def __init__(self, distribution: Distribution) -> None:
self._dist = distribution
self._called = False

Expand Down Expand Up @@ -430,7 +430,7 @@ class LazyMappingProxy(Mapping[_K, _V_co]):
'other value'
"""

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

Expand Down
4 changes: 2 additions & 2 deletions setuptools/config/pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __init__(
root_dir: StrPath | None = None,
ignore_option_errors: bool = False,
dist: Distribution | None = None,
):
) -> None:
self.config = config
self.root_dir = root_dir or os.getcwd()
self.project_cfg = config.get("project", {})
Expand Down Expand Up @@ -413,7 +413,7 @@ def _ignore_errors(ignore_option_errors: bool):
class _EnsurePackagesDiscovered(_expand.EnsurePackagesDiscovered):
def __init__(
self, distribution: Distribution, project_cfg: dict, setuptools_cfg: dict
):
) -> None:
super().__init__(distribution)
self._project_cfg = project_cfg
self._setuptools_cfg = setuptools_cfg
Expand Down
6 changes: 3 additions & 3 deletions setuptools/config/setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def __init__(
options: AllCommandOptions,
ignore_option_errors,
ensure_discovered: expand.EnsurePackagesDiscovered,
):
) -> None:
self.ignore_option_errors = ignore_option_errors
self.target_obj: Target = target_obj
self.sections = dict(self._section_options(options))
Expand Down Expand Up @@ -540,7 +540,7 @@ def __init__(
ensure_discovered: expand.EnsurePackagesDiscovered,
package_dir: dict | None = None,
root_dir: StrPath | None = os.curdir,
):
) -> None:
super().__init__(target_obj, options, ignore_option_errors, ensure_discovered)
self.package_dir = package_dir
self.root_dir = root_dir
Expand Down Expand Up @@ -602,7 +602,7 @@ def __init__(
options: AllCommandOptions,
ignore_option_errors: bool,
ensure_discovered: expand.EnsurePackagesDiscovered,
):
) -> None:
super().__init__(target_obj, options, ignore_option_errors, ensure_discovered)
self.root_dir = target_obj.src_root
self.package_dir: dict[str, str] = {} # To be filled by `find_packages`
Expand Down
2 changes: 1 addition & 1 deletion setuptools/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(
homepage: str = '',
attribute=None,
format=None,
):
) -> None:
if format is None and requested_version is not None:
format = Version

Expand Down
4 changes: 2 additions & 2 deletions setuptools/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _Filter:
the input matches at least one of the patterns.
"""

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

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

def __init__(self, distribution: Distribution):
def __init__(self, distribution: Distribution) -> None:
self.dist = distribution
self._called = False
self._disabled = False
Expand Down
2 changes: 1 addition & 1 deletion setuptools/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(
*args,
py_limited_api: bool = False,
**kw,
):
) -> None:
# The *args is needed for compatibility as calls may use positional
# arguments. py_limited_api may be set only via keyword.
self.py_limited_api = py_limited_api
Expand Down
8 changes: 4 additions & 4 deletions setuptools/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PlatformInfo:

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

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

@property
Expand Down Expand Up @@ -176,7 +176,7 @@ class RegistryInfo:
winreg.HKEY_CLASSES_ROOT,
)

def __init__(self, platform_info):
def __init__(self, platform_info) -> None:
self.pi = platform_info

@property
Expand Down Expand Up @@ -366,7 +366,7 @@ class SystemInfo:
ProgramFiles = environ.get('ProgramFiles', '')
ProgramFilesx86 = environ.get('ProgramFiles(x86)', ProgramFiles)

def __init__(self, registry_info, vc_ver=None):
def __init__(self, registry_info, vc_ver=None) -> None:
self.ri = registry_info
self.pi = self.ri.pi

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

def __init__(self, arch, vc_ver=None, vc_min_ver=0):
def __init__(self, arch, vc_ver=None, vc_min_ver=0) -> None:
self.pi = PlatformInfo(arch)
self.ri = RegistryInfo(self.pi)
self.si = SystemInfo(self.ri, vc_ver)
Expand Down
2 changes: 1 addition & 1 deletion setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class HashChecker(ContentChecker):
r'(?P<expected>[a-f0-9]+)'
)

def __init__(self, hash_name, expected):
def __init__(self, hash_name, expected) -> None:
self.hash_name = hash_name
self.hash = hashlib.new(hash_name)
self.expected = expected
Expand Down
4 changes: 2 additions & 2 deletions setuptools/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class AbstractSandbox:

_active = False

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

def __init__(self, sandbox, exceptions=_EXCEPTIONS):
def __init__(self, sandbox, exceptions=_EXCEPTIONS) -> None:
self._sandbox = os.path.normcase(os.path.realpath(sandbox))
self._prefix = os.path.join(self._sandbox, '')
self._exceptions = [
Expand Down
2 changes: 1 addition & 1 deletion setuptools/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def disable_info_traces():


class Wheel:
def __init__(self, filename):
def __init__(self, filename) -> None:
match = WHEEL_NAME(os.path.basename(filename))
if match is None:
raise ValueError('invalid wheel name: %r' % filename)
Expand Down

0 comments on commit 8343991

Please sign in to comment.