Skip to content

Commit

Permalink
Re-enable mypy & Resolve all [ignore-without-code]
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Oct 15, 2024
1 parent b7fce26 commit 857ded2
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ ignore_missing_imports = True

# Even when excluding a module, import issues can show up due to following import
# https://github.com/python/mypy/issues/11936#issuecomment-1466764006
[mypy-setuptools.config._validate_pyproject.*,setuptools._distutils.*]
[mypy-setuptools.config._validate_pyproject.*,setuptools._vendor.*,setuptools._distutils.*]
follow_imports = silent
# silent => ignore errors when following imports
2 changes: 1 addition & 1 deletion pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2777,7 +2777,7 @@ def load(
if require:
# We could pass `env` and `installer` directly,
# but keeping `*args` and `**kwargs` for backwards compatibility
self.require(*args, **kwargs) # type: ignore
self.require(*args, **kwargs) # type: ignore[arg-type]
return self.resolve()

def resolve(self) -> _ResolvedEntryPoint:
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,3 @@ formats = "zip"


[tool.setuptools_scm]


[tool.pytest-enabler.mypy]
# Disabled due to jaraco/skeleton#143
2 changes: 1 addition & 1 deletion setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def build_wheel(
):
cmd = ['bdist_wheel']
if metadata_directory:
cmd.extend(['--dist-info-dir', metadata_directory])
cmd.extend(['--dist-info-dir', str(metadata_directory)])
with suppress_known_deprecation():
return self._build_with_temp_dir(
cmd,
Expand Down
13 changes: 8 additions & 5 deletions setuptools/config/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def _load_spec(spec: ModuleSpec, module_name: str) -> ModuleType:
return sys.modules[name]
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module # cache (it also ensures `==` works on loaded items)
spec.loader.exec_module(module) # type: ignore
assert spec.loader is not None
spec.loader.exec_module(module)
return module


Expand Down Expand Up @@ -285,10 +286,11 @@ def find_packages(

from setuptools.discovery import construct_package_dir

if namespaces:
from setuptools.discovery import PEP420PackageFinder as PackageFinder
# check "not namespaces" first due to python/mypy#6232
if not namespaces:
from setuptools.discovery import PackageFinder
else:
from setuptools.discovery import PackageFinder # type: ignore
from setuptools.discovery import PEP420PackageFinder as PackageFinder

root_dir = root_dir or os.curdir
where = kwargs.pop('where', ['.'])
Expand Down Expand Up @@ -359,7 +361,8 @@ def entry_points(text: str, text_source="entry-points") -> dict[str, dict]:
entry-point names, and the second level values are references to objects
(that correspond to the entry-point value).
"""
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore
# Using undocumented behaviour, see python/typeshed#12700
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore[call-overload]
parser.optionxform = str # case sensitive
parser.read_string(text, text_source)
groups = {k: dict(v.items()) for k, v in parser.items()}
Expand Down
4 changes: 2 additions & 2 deletions setuptools/config/pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def validate(config: dict, filepath: StrPath) -> bool:

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

try:
return validator.validate(config)
Expand Down
2 changes: 1 addition & 1 deletion setuptools/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ def VCRuntimeRedist(self) -> str | None:
os.path.join(prefix, arch_subdir, crt_dir, vcruntime)
for (prefix, crt_dir) in itertools.product(prefixes, crt_dirs)
)
return next(filter(os.path.isfile, candidate_paths), None)
return next(filter(os.path.isfile, candidate_paths), None) # type: ignore[arg-type] #python/mypy#12682

def return_env(self, exists=True):
"""
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def get_build_ext_cmd(self, optional: bool, **opts):
"eggs.c": "#include missingheader.h\n",
".build": {"lib": {}, "tmp": {}},
}
path.build(files) # type: ignore[arg-type] # jaraco/path#232
path.build(files) # jaraco/path#232
extension = Extension('spam.eggs', ['eggs.c'], optional=optional)
dist = Distribution(dict(ext_modules=[extension]))
dist.script_name = 'setup.py'
Expand Down
14 changes: 9 additions & 5 deletions setuptools/tests/test_editable_install.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import platform
import stat
Expand All @@ -8,6 +10,7 @@
from importlib.machinery import EXTENSION_SUFFIXES
from pathlib import Path
from textwrap import dedent
from typing import Any
from unittest.mock import Mock
from uuid import uuid4

Expand Down Expand Up @@ -840,7 +843,8 @@ class TestOverallBehaviour:
version = "3.14159"
"""

FLAT_LAYOUT = {
# Any: Would need a TypedDict. Keep it simple for tests
FLAT_LAYOUT: dict[str, Any] = {
"pyproject.toml": dedent(PYPROJECT),
"MANIFEST.in": EXAMPLE["MANIFEST.in"],
"otherfile.py": "",
Expand Down Expand Up @@ -878,18 +882,18 @@ class TestOverallBehaviour:
"otherfile.py": "",
"mypkg": {
"__init__.py": "",
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"],
},
"other": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore
"other": FLAT_LAYOUT["mypkg"]["subpackage"],
},
"namespace": {
"pyproject.toml": dedent(PYPROJECT),
"MANIFEST.in": EXAMPLE["MANIFEST.in"],
"otherfile.py": "",
"src": {
"mypkg": {
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore
"subpackage": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"],
"subpackage": FLAT_LAYOUT["mypkg"]["subpackage"],
},
},
},
Expand Down

0 comments on commit 857ded2

Please sign in to comment.