Skip to content

Commit

Permalink
👹 Feed the hobgoblins (delint).
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 25, 2024
1 parent d93e241 commit b68509f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion importlib_resources/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ def _candidate_paths(cls, path_str):
def _resolve_zip_path(path_str):
for match in reversed(list(re.finditer(r'[\\/]', path_str))):
with contextlib.suppress(
FileNotFoundError, IsADirectoryError, NotADirectoryError, PermissionError
FileNotFoundError,
IsADirectoryError,
NotADirectoryError,
PermissionError,
):
inner = path_str[match.end() :].replace('\\', '/') + '/'
yield ZipPath(path_str[: match.start()], inner.lstrip('/'))
Expand Down
4 changes: 3 additions & 1 deletion importlib_resources/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def test_read_submodule_resource(self):

def test_read_submodule_resource_by_name(self):
result = (
resources.files('namespacedata01.subdirectory').joinpath('binary.file').read_bytes()
resources.files('namespacedata01.subdirectory')
.joinpath('binary.file')
.read_bytes()
)
self.assertEqual(result, b'\0\1\2\3')

Expand Down
4 changes: 3 additions & 1 deletion importlib_resources/tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def test_iterdir(self):
contents.remove('__pycache__')
except (KeyError, ValueError):
pass
self.assertEqual(contents, {'subdirectory', 'binary.file', 'utf-16.file', 'utf-8.file'})
self.assertEqual(
contents, {'subdirectory', 'binary.file', 'utf-16.file', 'utf-8.file'}
)

def test_iterdir_duplicate(self):
data01 = pathlib.Path(__file__).parent.joinpath('data01')
Expand Down
8 changes: 6 additions & 2 deletions importlib_resources/tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,19 @@ def test_submodule_contents(self):
contents.remove('__pycache__')
except KeyError:
pass
self.assertEqual(contents, {'subdirectory', 'binary.file', 'utf-8.file', 'utf-16.file'})
self.assertEqual(
contents, {'subdirectory', 'binary.file', 'utf-8.file', 'utf-16.file'}
)

def test_submodule_contents_by_name(self):
contents = names(resources.files('namespacedata01'))
try:
contents.remove('__pycache__')
except KeyError:
pass
self.assertEqual(contents, {'subdirectory', 'binary.file', 'utf-8.file', 'utf-16.file'})
self.assertEqual(
contents, {'subdirectory', 'binary.file', 'utf-8.file', 'utf-16.file'}
)

def test_submodule_sub_contents(self):
contents = names(resources.files(import_module('namespacedata01.subdirectory')))
Expand Down

0 comments on commit b68509f

Please sign in to comment.