Skip to content

Commit

Permalink
Use Ruff style, rather than PEP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Mar 21, 2024
1 parent 8fdadde commit 2df6ced
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
6 changes: 1 addition & 5 deletions importlib_resources/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ def contents(anchor, *path_names):
DeprecationWarning,
stacklevel=1,
)
return (
resource.name
for resource
in _get_resource(anchor, path_names).iterdir()
)
return (resource.name for resource in _get_resource(anchor, path_names).iterdir())


def _get_encoding_arg(path_names, encoding):
Expand Down
32 changes: 22 additions & 10 deletions importlib_resources/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class ModuleAnchorMixin:

class FunctionalAPIBase:
def _gen_resourcetxt_path_parts(self):
"""Yield various names of a text file in anchor02, each in a subTest
"""
"""Yield various names of a text file in anchor02, each in a subTest"""
for path_parts in (
('subdirectory', 'subsubdir', 'resource.txt'),
('subdirectory/subsubdir/resource.txt',),
Expand All @@ -44,15 +43,20 @@ def test_read_text(self):
)
self.assertEqual(
resources.read_text(
self.anchor02, 'subdirectory', 'subsubdir', 'resource.txt',
self.anchor02,
'subdirectory',
'subsubdir',
'resource.txt',
encoding='utf-8',
),
'a resource',
)
for path_parts in self._gen_resourcetxt_path_parts():
self.assertEqual(
resources.read_text(
self.anchor02, *path_parts, encoding='utf-8',
self.anchor02,
*path_parts,
encoding='utf-8',
),
'a resource',
)
Expand Down Expand Up @@ -99,7 +103,8 @@ def test_open_text(self):
self.assertEqual(f.read(), 'Hello, UTF-8 world!\n')
for path_parts in self._gen_resourcetxt_path_parts():
with resources.open_text(
self.anchor02, *path_parts,
self.anchor02,
*path_parts,
encoding='utf-8',
) as f:
self.assertEqual(f.read(), 'a resource')
Expand Down Expand Up @@ -135,7 +140,8 @@ def test_open_binary(self):
self.assertEqual(f.read(), b'Hello, UTF-8 world!\n')
for path_parts in self._gen_resourcetxt_path_parts():
with resources.open_binary(
self.anchor02, *path_parts,
self.anchor02,
*path_parts,
) as f:
self.assertEqual(f.read(), b'a resource')

Expand Down Expand Up @@ -213,18 +219,24 @@ def test_text_errors(self):
# Multiple path arguments need explicit encoding argument.
with self.assertRaises(TypeError):
func(
self.anchor02, 'subdirectory',
'subsubdir', 'resource.txt',
self.anchor02,
'subdirectory',
'subsubdir',
'resource.txt',
)


class FunctionalAPITest_StringAnchor(
unittest.TestCase, FunctionalAPIBase, StringAnchorMixin,
unittest.TestCase,
FunctionalAPIBase,
StringAnchorMixin,
):
pass


class FunctionalAPITest_ModuleAnchor(
unittest.TestCase, FunctionalAPIBase, ModuleAnchorMixin,
unittest.TestCase,
FunctionalAPIBase,
ModuleAnchorMixin,
):
pass

0 comments on commit 2df6ced

Please sign in to comment.