Skip to content

Commit

Permalink
🧎‍♀️ Genuflect to the types.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 21, 2024
1 parent 2fecb5e commit 045dde4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions importlib_resources/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def get_resource_reader(package: types.ModuleType) -> Optional[ResourceReader]:
# zipimport.zipimporter does not support weak references, resulting in a
# TypeError. That seems terrible.
spec = package.__spec__
reader = getattr(spec.loader, 'get_resource_reader', None) # type: ignore
reader = getattr(spec.loader, 'get_resource_reader', None) # type: ignore[union-attr]
if reader is None:
return None
return reader(spec.name) # type: ignore
return reader(spec.name) # type: ignore[union-attr]


@functools.singledispatch
Expand Down
4 changes: 2 additions & 2 deletions importlib_resources/compat/py39.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@


if sys.version_info >= (3, 10):
from zipfile import Path as ZipPath # type: ignore
from zipfile import Path as ZipPath
else:
from zipp import Path as ZipPath # type: ignore
from zipp import Path as ZipPath
2 changes: 1 addition & 1 deletion importlib_resources/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ResourceHandle(Traversable):

def __init__(self, parent: ResourceContainer, name: str):
self.parent = parent
self.name = name # type: ignore
self.name = name # type: ignore[misc]

def is_file(self):
return True
Expand Down
2 changes: 1 addition & 1 deletion importlib_resources/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_module_resources(self):
"""
A module can have resources found adjacent to the module.
"""
import mod
import mod # type: ignore[import-not-found]

actual = resources.files(mod).joinpath('res.txt').read_text(encoding='utf-8')
assert actual == self.spec['res.txt']
Expand Down

0 comments on commit 045dde4

Please sign in to comment.