Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit525037e

Browse files
authored
Autofixes formissing-return-type-special-method (ANN204) withignore-fully-untyped = false (#4802)
2 parents94ac34e +77514d3 commit525037e

File tree

9 files changed

+30
-20
lines changed

9 files changed

+30
-20
lines changed

‎ruff.toml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ ignore = [
6666
"UP038",# Using `X | Y` in `isinstance` call is slower and more verbose https://github.com/astral-sh/ruff/issues/7871
6767
# Only enforcing return type annotations for public functions
6868
"ANN202",# missing-return-type-private-function
69-
"ANN204",# missing-return-type-special-method
7069
]
7170

7271
[lint.per-file-ignores]
7372
# Suppress nuisance warnings about module-import-not-at-top-of-file (E402) due to workaround for #4476
7473
"setuptools/__init__.py" = ["E402"]
75-
"pkg_resources/__init__.py" = ["E402"]
74+
"pkg_resources/__init__.py" = ["E402","ANN204"]
7675

7776
[lint.isort]
7877
combine-as-imports =true

‎setuptools/command/build_py.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
fromfunctoolsimportpartial
1010
fromglobimportglob
1111
frompathlibimportPath
12+
fromtypingimportAny
1213

1314
frommore_itertoolsimportunique_everseen
1415

@@ -81,7 +82,8 @@ 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+
# Should return "list[tuple[str, str, str, list[str]]] | Any" but can't do without typed distutils on Python 3.12+
86+
def__getattr__(self,attr:str)->Any:
8587
"lazily compute data files"
8688
ifattr=='data_files':
8789
self.data_files=self._get_data_files()
@@ -381,8 +383,8 @@ class _Warning(SetuptoolsDeprecationWarning):
381383
# _DUE_DATE: still not defined as this is particularly controversial.
382384
# Warning initially introduced in May 2022. See issue #3340 for discussion.
383385

384-
def__init__(self):
385-
self._already_warned=set()
386+
def__init__(self)->None:
387+
self._already_warned=set[str]()
386388

387389
defis_module(self,file):
388390
returnfile.endswith(".py")andfile[:-len(".py")].isidentifier()

‎setuptools/command/editable_wheel.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> N
406406
self.name=name
407407
self.path_entries=path_entries
408408

409-
def__call__(self,wheel:WheelFile,files:list[str],mapping:Mapping[str,str]):
409+
def__call__(
410+
self,wheel:WheelFile,files:list[str],mapping:Mapping[str,str]
411+
)->None:
410412
entries="\n".join(str(p.resolve())forpinself.path_entries)
411413
contents=_encode_pth(f"{entries}\n")
412414
wheel.writestr(f"__editable__.{self.name}.pth",contents)
@@ -451,7 +453,9 @@ def __init__(
451453
self._file=dist.get_command_obj("build_py").copy_file
452454
super().__init__(dist,name, [self.auxiliary_dir])
453455

454-
def__call__(self,wheel:WheelFile,files:list[str],mapping:Mapping[str,str]):
456+
def__call__(
457+
self,wheel:WheelFile,files:list[str],mapping:Mapping[str,str]
458+
)->None:
455459
self._create_links(files,mapping)
456460
super().__call__(wheel,files,mapping)
457461

@@ -545,7 +549,9 @@ def get_implementation(self) -> Iterator[tuple[str, bytes]]:
545549
content=_encode_pth(f"import{finder};{finder}.install()")
546550
yield (f"__editable__.{self.name}.pth",content)
547551

548-
def__call__(self,wheel:WheelFile,files:list[str],mapping:Mapping[str,str]):
552+
def__call__(
553+
self,wheel:WheelFile,files:list[str],mapping:Mapping[str,str]
554+
)->None:
549555
forfile,contentinself.get_implementation():
550556
wheel.writestr(file,content)
551557

‎setuptools/config/expand.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _find_assignments(self) -> Iterator[tuple[ast.AST, ast.AST]]:
6565
elifisinstance(statement,ast.AnnAssign)andstatement.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
returnnext(

‎setuptools/discovery.py‎

Lines changed: 1 addition & 1 deletion
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

‎setuptools/tests/integration/helpers.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
facilitate debugging.
66
"""
77

8+
from __future__importannotations
9+
810
importos
911
importsubprocess
1012
importtarfile
13+
fromcollections.abcimportIterator
1114
frompathlibimportPath
12-
fromzipfileimportZipFile
15+
fromzipfileimportZipFile,ZipInfo
1316

1417

1518
defrun(cmd,env=None):
@@ -35,16 +38,16 @@ def run(cmd, env=None):
3538
classArchive:
3639
"""Compatibility layer for ZipFile/Info and TarFile/Info"""
3740

38-
def__init__(self,filename):
41+
def__init__(self,filename)->None:
3942
self._filename=filename
4043
iffilename.endswith("tar.gz"):
41-
self._obj=tarfile.open(filename,"r:gz")
44+
self._obj:tarfile.TarFile|ZipFile=tarfile.open(filename,"r:gz")
4245
eliffilename.endswith("zip"):
4346
self._obj=ZipFile(filename)
4447
else:
4548
raiseValueError(f"{filename} doesn't seem to be a zip or tar.gz")
4649

47-
def__iter__(self):
50+
def__iter__(self)->Iterator[ZipInfo]|Iterator[tarfile.TarInfo]:
4851
ifhasattr(self._obj,"infolist"):
4952
returniter(self._obj.infolist())
5053
returniter(self._obj)

‎setuptools/tests/test_bdist_wheel.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def test_preserve_unicode_metadata(monkeypatch, tmp_path):
295295
classsimpler_bdist_wheel(bdist_wheel):
296296
"""Avoid messing with setuptools/distutils internals"""
297297

298-
def__init__(self):
298+
def__init__(self)->None:
299299
pass
300300

301301
@property

‎setuptools/tests/test_build_meta.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
classBuildBackendBase:
38-
def__init__(self,cwd='.',env=None,backend_name='setuptools.build_meta'):
38+
def__init__(self,cwd='.',env=None,backend_name='setuptools.build_meta')->None:
3939
self.cwd=cwd
4040
self.env=envor {}
4141
self.backend_name=backend_name
@@ -44,7 +44,7 @@ def __init__(self, cwd='.', env=None, backend_name='setuptools.build_meta'):
4444
classBuildBackend(BuildBackendBase):
4545
"""PEP 517 Build Backend"""
4646

47-
def__init__(self,*args,**kwargs):
47+
def__init__(self,*args,**kwargs)->None:
4848
super().__init__(*args,**kwargs)
4949
self.pool=futures.ProcessPoolExecutor(max_workers=1)
5050

@@ -77,12 +77,12 @@ def _kill(self, pid):
7777

7878

7979
classBuildBackendCaller(BuildBackendBase):
80-
def__init__(self,*args,**kwargs):
80+
def__init__(self,*args,**kwargs)->None:
8181
super().__init__(*args,**kwargs)
8282

8383
(self.backend_name,_,self.backend_obj)=self.backend_name.partition(':')
8484

85-
def__call__(self,name,*args,**kw):
85+
def__call__(self,name,*args,**kw)->Any:
8686
"""Handles arbitrary function invocations on the build backend."""
8787
os.chdir(self.cwd)
8888
os.environ.update(self.env)

‎setuptools/tests/test_wheel.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _check_wheel_install(
168168

169169

170170
classRecord:
171-
def__init__(self,id,**kwargs):
171+
def__init__(self,id,**kwargs)->None:
172172
self._id=id
173173
self._fields=kwargs
174174

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp