Skip to content

Commit 377cd71

Browse files
committed
Resolve all [ignore-without-code]
1 parent 267ffac commit 377cd71

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

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:

setuptools/config/expand.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ 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+
if spec.loader is None:
207+
raise AttributeError(f"spec {spec} is missing a loader")
208+
spec.loader.exec_module(module)
207209
return module
208210

209211

@@ -285,10 +287,10 @@ def find_packages(
285287

286288
from setuptools.discovery import construct_package_dir
287289

288-
if namespaces:
289-
from setuptools.discovery import PEP420PackageFinder as PackageFinder
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+
# TODO: Explain why passing None is fine here when ConfigParser.default_section expects to be str
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_editable_install.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,18 +878,18 @@ class TestOverallBehaviour:
878878
"otherfile.py": "",
879879
"mypkg": {
880880
"__init__.py": "",
881-
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore
881+
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore[index] # Would need a TypedDict
882882
},
883-
"other": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore
883+
"other": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore[index] # Would need a TypedDict
884884
},
885885
"namespace": {
886886
"pyproject.toml": dedent(PYPROJECT),
887887
"MANIFEST.in": EXAMPLE["MANIFEST.in"],
888888
"otherfile.py": "",
889889
"src": {
890890
"mypkg": {
891-
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore
892-
"subpackage": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore
891+
"mod1.py": FLAT_LAYOUT["mypkg"]["mod1.py"], # type: ignore[index] # Would need a TypedDict
892+
"subpackage": FLAT_LAYOUT["mypkg"]["subpackage"], # type: ignore[index] # Would need a TypedDict
893893
},
894894
},
895895
},

0 commit comments

Comments
 (0)