Skip to content

Commit 34074c1

Browse files
committed
lint
1 parent 6b6b0e6 commit 34074c1

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

fsspec/implementations/asyn_wrapper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ def async_wrapper(func, obj=None):
2020
coroutine
2121
An awaitable version of the function.
2222
"""
23+
2324
@functools.wraps(func)
2425
async def wrapper(*args, **kwargs):
25-
self = obj or args[0]
2626
return await asyncio.to_thread(func, *args, **kwargs)
27+
2728
return wrapper
2829

2930

@@ -39,6 +40,7 @@ class AsyncFileSystemWrapper(AsyncFileSystem):
3940
sync_fs : AbstractFileSystem
4041
The synchronous filesystem instance to wrap.
4142
"""
43+
4244
def __init__(self, sync_fs, *args, **kwargs):
4345
super().__init__(*args, **kwargs)
4446
self.asynchronous = True
@@ -82,10 +84,13 @@ def wrap_class(cls, sync_fs_class):
8284
type
8385
A new class that wraps the provided synchronous filesystem class.
8486
"""
87+
8588
class GeneratedAsyncFileSystemWrapper(cls):
8689
def __init__(self, *args, **kwargs):
8790
sync_fs = sync_fs_class(*args, **kwargs)
8891
super().__init__(sync_fs)
8992

90-
GeneratedAsyncFileSystemWrapper.__name__ = f"Async{sync_fs_class.__name__}Wrapper"
91-
return GeneratedAsyncFileSystemWrapper
93+
GeneratedAsyncFileSystemWrapper.__name__ = (
94+
f"Async{sync_fs_class.__name__}Wrapper"
95+
)
96+
return GeneratedAsyncFileSystemWrapper

fsspec/implementations/tests/test_asyn_wrapper.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,31 @@
1111
def test_is_async():
1212
fs = fsspec.filesystem("file")
1313
async_fs = AsyncFileSystemWrapper(fs)
14-
assert async_fs.async_impl == True
14+
assert async_fs.async_impl
1515

1616

1717
def test_class_wrapper():
1818
fs_cls = LocalFileSystem
1919
async_fs_cls = AsyncFileSystemWrapper.wrap_class(fs_cls)
2020
assert async_fs_cls.__name__ == "AsyncLocalFileSystemWrapper"
2121
async_fs = async_fs_cls()
22-
assert async_fs.async_impl == True
22+
assert async_fs.async_impl
2323

2424

2525
@pytest.mark.asyncio
2626
async def test_cats():
2727
with filetexts(csv_files, mode="b"):
2828
fs = fsspec.filesystem("file")
2929
async_fs = AsyncFileSystemWrapper(fs)
30-
30+
3131
result = await async_fs._cat(".test.fakedata.1.csv")
3232
assert result == b"a,b\n1,2\n"
3333

34-
out = set((await async_fs._cat([".test.fakedata.1.csv", ".test.fakedata.2.csv"])).values())
34+
out = set(
35+
(
36+
await async_fs._cat([".test.fakedata.1.csv", ".test.fakedata.2.csv"])
37+
).values()
38+
)
3539
assert out == {b"a,b\n1,2\n", b"a,b\n3,4\n"}
3640

3741
result = await async_fs._cat(".test.fakedata.1.csv", None, None)
@@ -51,12 +55,15 @@ async def test_cats():
5155
assert result == b"a,b\n1,2\n"[1:-2]
5256

5357
out = set(
54-
(await async_fs._cat(
55-
[".test.fakedata.1.csv", ".test.fakedata.2.csv"], start=1, end=-1
56-
)).values()
58+
(
59+
await async_fs._cat(
60+
[".test.fakedata.1.csv", ".test.fakedata.2.csv"], start=1, end=-1
61+
)
62+
).values()
5763
)
5864
assert out == {b"a,b\n1,2\n"[1:-1], b"a,b\n3,4\n"[1:-1]}
5965

66+
6067
@pytest.mark.asyncio
6168
async def test_basic_crud_operations():
6269
with filetexts(csv_files, mode="b"):
@@ -76,6 +83,7 @@ async def test_basic_crud_operations():
7683
await async_fs._rm(".test.fakedata.1.csv")
7784
assert not await async_fs._exists(".test.fakedata.1.csv")
7885

86+
7987
@pytest.mark.asyncio
8088
async def test_error_handling():
8189
fs = fsspec.filesystem("file")
@@ -87,6 +95,7 @@ async def test_error_handling():
8795
with pytest.raises(FileNotFoundError):
8896
await async_fs._rm(".test.non_existent.csv")
8997

98+
9099
@pytest.mark.asyncio
91100
async def test_concurrent_operations():
92101
with filetexts(csv_files, mode="b"):
@@ -99,11 +108,12 @@ async def read_file(file_path):
99108
results = await asyncio.gather(
100109
read_file(".test.fakedata.1.csv"),
101110
read_file(".test.fakedata.2.csv"),
102-
read_file(".test.fakedata.1.csv")
111+
read_file(".test.fakedata.1.csv"),
103112
)
104113

105114
assert results == [b"a,b\n1,2\n", b"a,b\n3,4\n", b"a,b\n1,2\n"]
106115

116+
107117
@pytest.mark.asyncio
108118
async def test_directory_operations():
109119
with filetexts(csv_files, mode="b"):
@@ -120,6 +130,7 @@ async def test_directory_operations():
120130
assert ".test.fakedata.2.csv" in filenames
121131
assert "new_directory" in filenames
122132

133+
123134
@pytest.mark.asyncio
124135
async def test_batch_operations():
125136
with filetexts(csv_files, mode="b"):
@@ -128,4 +139,4 @@ async def test_batch_operations():
128139

129140
await async_fs._rm([".test.fakedata.1.csv", ".test.fakedata.2.csv"])
130141
assert not await async_fs._exists(".test.fakedata.1.csv")
131-
assert not await async_fs._exists(".test.fakedata.2.csv")
142+
assert not await async_fs._exists(".test.fakedata.2.csv")

0 commit comments

Comments
 (0)