Skip to content

Commit 04c6983

Browse files
committed
Pass mypy and link issues
1 parent f9a91a1 commit 04c6983

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

importlib_metadata/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __str__(self) -> str:
6666
return f"No package metadata was found for {self.name}"
6767

6868
@property
69-
def name(self) -> str: # type: ignore[override]
69+
def name(self) -> str: # type: ignore[override] # make readonly
7070
(name,) = self.args
7171
return name
7272

@@ -284,7 +284,7 @@ class EntryPoints(tuple):
284284

285285
__slots__ = ()
286286

287-
def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override]
287+
def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override] # Work with str instead of int
288288
"""
289289
Get the EntryPoint in self matching name.
290290
"""

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,3 @@ type = [
7777

7878

7979
[tool.setuptools_scm]
80-
81-
82-
[tool.pytest-enabler.mypy]
83-
# Disabled due to jaraco/skeleton#143

tests/_path.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ def symlink_to(self, target): ... # pragma: no cover
2828

2929

3030
def _ensure_tree_maker(obj: Union[str, TreeMaker]) -> TreeMaker:
31-
return obj if isinstance(obj, TreeMaker) else pathlib.Path(obj) # type: ignore[return-value]
31+
return obj if isinstance(obj, TreeMaker) else pathlib.Path(obj) # type: ignore[return-value] # jaraco/jaraco.path#4
3232

3333

3434
def build(
3535
spec: FilesSpec,
36-
prefix: Union[str, TreeMaker] = pathlib.Path(), # type: ignore[assignment]
36+
prefix: Union[str, TreeMaker] = pathlib.Path(), # type: ignore[assignment] # jaraco/jaraco.path#4
3737
):
3838
"""
3939
Build a set of files/directories, as described by the spec.
@@ -67,7 +67,8 @@ def build(
6767
@functools.singledispatch
6868
def create(content: Union[str, bytes, FilesSpec], path):
6969
path.mkdir(exist_ok=True)
70-
build(content, prefix=path) # type: ignore[arg-type]
70+
# Mypy only looks at the signature of the main singledispatch method. So it must contain the complete Union
71+
build(content, prefix=path) # type: ignore[arg-type] # python/mypy#11727
7172

7273

7374
@create.register

tests/fixtures.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
from .compat.py39 import os_helper
1313
from .compat.py312 import import_helper
1414

15-
try:
15+
if sys.version_info >= (3, 9):
1616
from importlib import resources
17-
18-
getattr(resources, 'files')
19-
getattr(resources, 'as_file')
20-
except (ImportError, AttributeError):
21-
import importlib_resources as resources # type: ignore[import-not-found, no-redef, unused-ignore]
17+
else:
18+
import importlib_resources as resources
2219

2320

2421
@contextlib.contextmanager

0 commit comments

Comments
 (0)