Skip to content

Commit 3403ffd

Browse files
Avasamabravalheri
authored andcommitted
Re-enable mypy & Resolve all [ignore-without-code]
1 parent ecde60b commit 3403ffd

File tree

9 files changed

+24
-21
lines changed

9 files changed

+24
-21
lines changed

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ ignore_missing_imports = True
6464

6565
# Even when excluding a module, import issues can show up due to following import
6666
# https://github.com/python/mypy/issues/11936#issuecomment-1466764006
67-
[mypy-setuptools.config._validate_pyproject.*,setuptools._distutils.*]
67+
[mypy-setuptools.config._validate_pyproject.*,setuptools._vendor.*,setuptools._distutils.*]
6868
follow_imports = silent
6969
# silent => ignore errors when following imports

pkg_resources/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ def load(
27772777
if require:
27782778
# We could pass `env` and `installer` directly,
27792779
# but keeping `*args` and `**kwargs` for backwards compatibility
2780-
self.require(*args, **kwargs) # type: ignore
2780+
self.require(*args, **kwargs) # type: ignore[arg-type]
27812781
return self.resolve()
27822782

27832783
def resolve(self) -> _ResolvedEntryPoint:

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,3 @@ formats = "zip"
216216

217217

218218
[tool.setuptools_scm]
219-
220-
221-
[tool.pytest-enabler.mypy]
222-
# Disabled due to jaraco/skeleton#143

setuptools/build_meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def _build(cmd: list[str]):
431431
return _build(['bdist_wheel'])
432432

433433
try:
434-
return _build(['bdist_wheel', '--dist-info-dir', metadata_directory])
434+
return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
435435
except SystemExit as ex: # pragma: nocover
436436
# pypa/setuptools#4683
437437
if "--dist-info-dir not recognized" not in str(ex):

setuptools/config/expand.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ def _load_spec(spec: ModuleSpec, module_name: str) -> ModuleType:
203203
return sys.modules[name]
204204
module = importlib.util.module_from_spec(spec)
205205
sys.modules[name] = module # cache (it also ensures `==` works on loaded items)
206-
spec.loader.exec_module(module) # type: ignore
206+
assert spec.loader is not None
207+
spec.loader.exec_module(module)
207208
return module
208209

209210

@@ -285,10 +286,11 @@ def find_packages(
285286

286287
from setuptools.discovery import construct_package_dir
287288

288-
if namespaces:
289-
from setuptools.discovery import PEP420PackageFinder as PackageFinder
289+
# check "not namespaces" first due to python/mypy#6232
290+
if not namespaces:
291+
from setuptools.discovery import PackageFinder
290292
else:
291-
from setuptools.discovery import PackageFinder # type: ignore
293+
from setuptools.discovery import PEP420PackageFinder as PackageFinder
292294

293295
root_dir = root_dir or os.curdir
294296
where = kwargs.pop('where', ['.'])
@@ -359,7 +361,8 @@ def entry_points(text: str, text_source="entry-points") -> dict[str, dict]:
359361
entry-point names, and the second level values are references to objects
360362
(that correspond to the entry-point value).
361363
"""
362-
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore
364+
# Using undocumented behaviour, see python/typeshed#12700
365+
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore[call-overload]
363366
parser.optionxform = str # case sensitive
364367
parser.read_string(text, text_source)
365368
groups = {k: dict(v.items()) for k, v in parser.items()}

setuptools/config/pyprojecttoml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def validate(config: dict, filepath: StrPath) -> bool:
4444

4545
trove_classifier = validator.FORMAT_FUNCTIONS.get("trove-classifier")
4646
if hasattr(trove_classifier, "_disable_download"):
47-
# Improve reproducibility by default. See issue 31 for validate-pyproject.
48-
trove_classifier._disable_download() # type: ignore
47+
# Improve reproducibility by default. See abravalheri/validate-pyproject#31
48+
trove_classifier._disable_download() # type: ignore[union-attr]
4949

5050
try:
5151
return validator.validate(config)

setuptools/msvc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ def VCRuntimeRedist(self) -> str | None:
14181418
os.path.join(prefix, arch_subdir, crt_dir, vcruntime)
14191419
for (prefix, crt_dir) in itertools.product(prefixes, crt_dirs)
14201420
)
1421-
return next(filter(os.path.isfile, candidate_paths), None)
1421+
return next(filter(os.path.isfile, candidate_paths), None) # type: ignore[arg-type] #python/mypy#12682
14221422

14231423
def return_env(self, exists=True):
14241424
"""

setuptools/tests/test_build_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def get_build_ext_cmd(self, optional: bool, **opts):
183183
"eggs.c": "#include missingheader.h\n",
184184
".build": {"lib": {}, "tmp": {}},
185185
}
186-
path.build(files) # type: ignore[arg-type] # jaraco/path#232
186+
path.build(files) # jaraco/path#232
187187
extension = Extension('spam.eggs', ['eggs.c'], optional=optional)
188188
dist = Distribution(dict(ext_modules=[extension]))
189189
dist.script_name = 'setup.py'

setuptools/tests/test_editable_install.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import os
24
import platform
35
import stat
@@ -8,6 +10,7 @@
810
from importlib.machinery import EXTENSION_SUFFIXES
911
from pathlib import Path
1012
from textwrap import dedent
13+
from typing import Any
1114
from unittest.mock import Mock
1215
from uuid import uuid4
1316

@@ -840,7 +843,8 @@ class TestOverallBehaviour:
840843
version = "3.14159"
841844
"""
842845

843-
FLAT_LAYOUT = {
846+
# Any: Would need a TypedDict. Keep it simple for tests
847+
FLAT_LAYOUT: dict[str, Any] = {
844848
"pyproject.toml": dedent(PYPROJECT),
845849
"MANIFEST.in": EXAMPLE["MANIFEST.in"],
846850
"otherfile.py": "",
@@ -878,18 +882,18 @@ class TestOverallBehaviour:
878882
"otherfile.py": "",
879883
"mypkg": {
880884
"__init__.py": "",
881-
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore
885+
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"],
882886
},
883-
"other": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore
887+
"other": FLAT_LAYOUT["mypkg"]["subpackage"],
884888
},
885889
"namespace": {
886890
"pyproject.toml": dedent(PYPROJECT),
887891
"MANIFEST.in": EXAMPLE["MANIFEST.in"],
888892
"otherfile.py": "",
889893
"src": {
890894
"mypkg": {
891-
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore
892-
"subpackage": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore
895+
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"],
896+
"subpackage": FLAT_LAYOUT["mypkg"]["subpackage"],
893897
},
894898
},
895899
},

0 commit comments

Comments
 (0)