From fb95489244a9568bc17f0178a3f51cd42f18cb5e Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 27 Aug 2024 14:46:58 -0400 Subject: [PATCH] Resolve all [ignore-without-code] --- pkg_resources/__init__.py | 2 +- setuptools/config/expand.py | 13 ++++++++----- setuptools/config/pyprojecttoml.py | 4 ++-- setuptools/msvc.py | 2 +- setuptools/tests/test_editable_install.py | 8 ++++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 4e9b83d83d..f1f0ef2535 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -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: diff --git a/setuptools/config/expand.py b/setuptools/config/expand.py index e11bcf9b42..9237bcbffa 100644 --- a/setuptools/config/expand.py +++ b/setuptools/config/expand.py @@ -203,7 +203,9 @@ 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 + if spec.loader is None: + raise AttributeError(f"spec {spec} is missing a loader") + spec.loader.exec_module(module) return module @@ -285,10 +287,10 @@ def find_packages( from setuptools.discovery import construct_package_dir - if namespaces: - from setuptools.discovery import PEP420PackageFinder as PackageFinder + 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', ['.']) @@ -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 + # TODO: Explain why passing None is fine here when ConfigParser.default_section expects to be str + 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()} diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index 5d95e18b83..e0040cefbd 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -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) diff --git a/setuptools/msvc.py b/setuptools/msvc.py index de4b05f928..7ee685e023 100644 --- a/setuptools/msvc.py +++ b/setuptools/msvc.py @@ -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): """ diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py index 287367ac18..92793b05a2 100644 --- a/setuptools/tests/test_editable_install.py +++ b/setuptools/tests/test_editable_install.py @@ -878,9 +878,9 @@ class TestOverallBehaviour: "otherfile.py": "", "mypkg": { "__init__.py": "", - "mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore + "mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore[index] # Would need a TypedDict }, - "other": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore + "other": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore[index] # Would need a TypedDict }, "namespace": { "pyproject.toml": dedent(PYPROJECT), @@ -888,8 +888,8 @@ class TestOverallBehaviour: "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"], # type: ignore[index] # Would need a TypedDict + "subpackage": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore[index] # Would need a TypedDict }, }, },