Skip to content

Commit c9eaa26

Browse files
committed
ANN204 w/o ignore-fully-untyped
1 parent a443f76 commit c9eaa26

File tree

9 files changed

+26
-19
lines changed

9 files changed

+26
-19
lines changed

Diff for: pkg_resources/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
if TYPE_CHECKING:
9494
from _typeshed import BytesPath, StrOrBytesPath, StrPath
9595
from _typeshed.importlib import LoaderProtocol
96-
from typing_extensions import Self, TypeAlias
96+
from typing_extensions import Never, Self, TypeAlias
9797

9898
warnings.warn(
9999
"pkg_resources is deprecated as an API. "
@@ -2365,7 +2365,7 @@ class NoDists:
23652365
def __bool__(self) -> Literal[False]:
23662366
return False
23672367

2368-
def __call__(self, fullpath: object):
2368+
def __call__(self, fullpath: object) -> Iterator[Never]:
23692369
return iter(())
23702370

23712371

@@ -3163,13 +3163,13 @@ def __str__(self) -> str:
31633163
version = version or "[unknown version]"
31643164
return f"{self.project_name} {version}"
31653165

3166-
def __getattr__(self, attr: str):
3166+
def __getattr__(self, attr: str) -> Any:
31673167
"""Delegate all unrecognized public attributes to .metadata provider"""
31683168
if attr.startswith('_'):
31693169
raise AttributeError(attr)
31703170
return getattr(self._provider, attr)
31713171

3172-
def __dir__(self):
3172+
def __dir__(self) -> list[str]:
31733173
return list(
31743174
set(super().__dir__())
31753175
| set(attr for attr in self._provider.__dir__() if not attr.startswith('_'))

Diff for: ruff.toml

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ ignore = [
3838
"UP038", # Using `X | Y` in `isinstance` call is slower and more verbose https://github.com/astral-sh/ruff/issues/7871
3939
# Only enforcing return type annotations for public functions
4040
"ANN202", # missing-return-type-private-function
41-
"ANN204", # missing-return-type-special-method
4241

4342
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
4443
"W191",

Diff for: setuptools/command/build_py.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from functools import partial
1010
from glob import glob
1111
from pathlib import Path
12+
from typing import Any
1213

1314
from more_itertools import unique_everseen
1415

@@ -81,7 +82,7 @@ def run(self) -> None:
8182
# output files are.
8283
self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=False))
8384

84-
def __getattr__(self, attr: str):
85+
def __getattr__(self, attr: str) -> list[tuple[str, str, str, list[str]]] | Any:
8586
"lazily compute data files"
8687
if attr == 'data_files':
8788
self.data_files = self._get_data_files()
@@ -381,8 +382,8 @@ class _Warning(SetuptoolsDeprecationWarning):
381382
# _DUE_DATE: still not defined as this is particularly controversial.
382383
# Warning initially introduced in May 2022. See issue #3340 for discussion.
383384

384-
def __init__(self):
385-
self._already_warned = set()
385+
def __init__(self) -> None:
386+
self._already_warned = set[str]()
386387

387388
def is_module(self, file):
388389
return file.endswith(".py") and file[: -len(".py")].isidentifier()

Diff for: setuptools/command/develop.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import glob
22
import os
3+
from typing import Any
34

45
import setuptools
56
from setuptools import _normalization, _path, namespaces
@@ -188,7 +189,7 @@ class VersionlessRequirement:
188189
def __init__(self, dist) -> None:
189190
self.__dist = dist
190191

191-
def __getattr__(self, name: str):
192+
def __getattr__(self, name: str) -> Any:
192193
return getattr(self.__dist, name)
193194

194195
def as_requirement(self):

Diff for: setuptools/command/editable_wheel.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@ def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> N
397397
self.name = name
398398
self.path_entries = path_entries
399399

400-
def __call__(self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]):
400+
def __call__(
401+
self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]
402+
) -> None:
401403
entries = "\n".join(str(p.resolve()) for p in self.path_entries)
402404
contents = _encode_pth(f"{entries}\n")
403405
wheel.writestr(f"__editable__.{self.name}.pth", contents)
@@ -442,7 +444,9 @@ def __init__(
442444
self._file = dist.get_command_obj("build_py").copy_file
443445
super().__init__(dist, name, [self.auxiliary_dir])
444446

445-
def __call__(self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]):
447+
def __call__(
448+
self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]
449+
) -> None:
446450
self._create_links(files, mapping)
447451
super().__call__(wheel, files, mapping)
448452

@@ -536,7 +540,9 @@ def get_implementation(self) -> Iterator[tuple[str, bytes]]:
536540
content = _encode_pth(f"import {finder}; {finder}.install()")
537541
yield (f"__editable__.{self.name}.pth", content)
538542

539-
def __call__(self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]):
543+
def __call__(
544+
self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]
545+
) -> None:
540546
for file, content in self.get_implementation():
541547
wheel.writestr(file, content)
542548

Diff for: setuptools/config/expand.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _find_assignments(self) -> Iterator[tuple[ast.AST, ast.AST]]:
6565
elif isinstance(statement, ast.AnnAssign) and statement.value:
6666
yield (statement.target, statement.value)
6767

68-
def __getattr__(self, attr: str):
68+
def __getattr__(self, attr: str) -> Any:
6969
"""Attempt to load an attribute "statically", via :func:`ast.literal_eval`."""
7070
try:
7171
return next(
@@ -390,7 +390,7 @@ def __init__(self, distribution: Distribution) -> None:
390390
self._dist = distribution
391391
self._called = False
392392

393-
def __call__(self):
393+
def __call__(self) -> None:
394394
"""Trigger the automatic package discovery, if it is still necessary."""
395395
if not self._called:
396396
self._called = True
@@ -404,7 +404,7 @@ def __exit__(
404404
exc_type: type[BaseException] | None,
405405
exc_value: BaseException | None,
406406
traceback: TracebackType | None,
407-
):
407+
) -> None:
408408
if self._called:
409409
self._dist.set_defaults.analyse_name() # Now we can set a default name
410410

Diff for: setuptools/discovery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _package_dir(self) -> dict[str, str]:
335335

336336
def __call__(
337337
self, force: bool = False, name: bool = True, ignore_ext_modules: bool = False
338-
):
338+
) -> None:
339339
"""Automatically discover missing configuration fields
340340
and modifies the given ``distribution`` object in-place.
341341

Diff for: setuptools/package_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ def __str__(self) -> str:
10071007

10081008

10091009
class PyPIConfig(configparser.RawConfigParser):
1010-
def __init__(self):
1010+
def __init__(self) -> None:
10111011
"""
10121012
Load from ~/.pypirc
10131013
"""

Diff for: setuptools/sandbox.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def __exit__(
300300
exc_type: type[BaseException] | None,
301301
exc_value: BaseException | None,
302302
traceback: TracebackType | None,
303-
):
303+
) -> None:
304304
self._active = False
305305
builtins.open = _open
306306
self._copy(_os)
@@ -411,7 +411,7 @@ def _remap_pair(self, operation, src, dst, *args, **kw):
411411
if TYPE_CHECKING:
412412
# This is a catch-all for all the dynamically created attributes.
413413
# This isn't public API anyway
414-
def __getattribute__(self, name: str) -> Any: ...
414+
def __getattr__(self, name: str) -> Any: ...
415415

416416

417417
if hasattr(os, 'devnull'):

0 commit comments

Comments
 (0)