Skip to content

Commit ee98ae3

Browse files
Apply more ruff rules (#1660)
1 parent 4f883ad commit ee98ae3

19 files changed

+32
-54
lines changed

fsspec/asyn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ async def flush(self, force=False):
10721072
self.offset = 0
10731073
try:
10741074
await self._initiate_upload()
1075-
except: # noqa: E722
1075+
except:
10761076
self.closed = True
10771077
raise
10781078

fsspec/implementations/arrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def cp_file(self, path1, path2, **kwargs):
128128
with self.open(tmp_fname, "wb") as rstream:
129129
shutil.copyfileobj(lstream, rstream)
130130
self.fs.move(tmp_fname, path2)
131-
except BaseException: # noqa
131+
except BaseException:
132132
with suppress(FileNotFoundError):
133133
self.fs.delete_file(tmp_fname)
134134
raise

fsspec/implementations/dbfs.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def ls(self, path, detail=True, **kwargs):
7979
if e.error_code == "RESOURCE_DOES_NOT_EXIST":
8080
raise FileNotFoundError(e.message) from e
8181

82-
raise e
82+
raise
8383
files = r["files"]
8484
out = [
8585
{
@@ -125,7 +125,7 @@ def makedirs(self, path, exist_ok=True):
125125
if e.error_code == "RESOURCE_ALREADY_EXISTS":
126126
raise FileExistsError(e.message) from e
127127

128-
raise e
128+
raise
129129
self.invalidate_cache(self._parent(path))
130130

131131
def mkdir(self, path, create_parents=True, **kwargs):
@@ -171,7 +171,7 @@ def rm(self, path, recursive=False, **kwargs):
171171
# Using the same exception as the os module would use here
172172
raise OSError(e.message) from e
173173

174-
raise e
174+
raise
175175
self.invalidate_cache(self._parent(path))
176176

177177
def mv(
@@ -216,7 +216,7 @@ def mv(
216216
elif e.error_code == "RESOURCE_ALREADY_EXISTS":
217217
raise FileExistsError(e.message) from e
218218

219-
raise e
219+
raise
220220
self.invalidate_cache(self._parent(source_path))
221221
self.invalidate_cache(self._parent(destination_path))
222222

@@ -299,7 +299,7 @@ def _create_handle(self, path, overwrite=True):
299299
if e.error_code == "RESOURCE_ALREADY_EXISTS":
300300
raise FileExistsError(e.message) from e
301301

302-
raise e
302+
raise
303303

304304
def _close_handle(self, handle):
305305
"""
@@ -316,7 +316,7 @@ def _close_handle(self, handle):
316316
if e.error_code == "RESOURCE_DOES_NOT_EXIST":
317317
raise FileNotFoundError(e.message) from e
318318

319-
raise e
319+
raise
320320

321321
def _add_data(self, handle, data):
322322
"""
@@ -346,7 +346,7 @@ def _add_data(self, handle, data):
346346
elif e.error_code == "MAX_BLOCK_SIZE_EXCEEDED":
347347
raise ValueError(e.message) from e
348348

349-
raise e
349+
raise
350350

351351
def _get_data(self, path, start, end):
352352
"""
@@ -376,7 +376,7 @@ def _get_data(self, path, start, end):
376376
elif e.error_code in ["INVALID_PARAMETER_VALUE", "MAX_READ_SIZE_EXCEEDED"]:
377377
raise ValueError(e.message) from e
378378

379-
raise e
379+
raise
380380

381381
def invalidate_cache(self, path=None):
382382
if path is None:

fsspec/implementations/reference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def open_refs(field, record):
159159
path = self.url.format(field=field, record=record)
160160
data = io.BytesIO(self.fs.cat_file(path))
161161
df = self.pd.read_parquet(data, engine="fastparquet")
162-
refs = {c: df[c].values for c in df.columns}
162+
refs = {c: df[c].to_numpy() for c in df.columns}
163163
return refs
164164

165165
self.open_refs = open_refs

fsspec/implementations/smb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _connect(self):
202202
else:
203203
# All another ValueError exceptions should be raised, as they are not
204204
# related to network issues.
205-
raise exc
205+
raise
206206
except Exception as exc:
207207
# Save the exception and retry to connect. This except might be dropped
208208
# in the future, once all exceptions suited for retry are identified.

fsspec/implementations/tests/test_arrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pyarrow_fs = pytest.importorskip("pyarrow.fs")
66
FileSystem = pyarrow_fs.FileSystem
77

8-
from fsspec.implementations.arrow import ArrowFSWrapper, HadoopFileSystem # noqa
8+
from fsspec.implementations.arrow import ArrowFSWrapper, HadoopFileSystem # noqa: E402
99

1010

1111
@pytest.fixture(scope="function")

fsspec/implementations/tests/test_reference.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from fsspec.tests.conftest import data, realfile, reset_files, server, win # noqa: F401
1414

1515

16-
def test_simple(server): # noqa: F811
16+
def test_simple(server):
1717
# The dictionary in refs may be dumped with a different separator
1818
# depending on whether json or ujson is imported
1919
from fsspec.implementations.reference import json as json_impl
@@ -37,7 +37,7 @@ def test_simple(server): # noqa: F811
3737
assert f.read(2) == "he"
3838

3939

40-
def test_simple_ver1(server): # noqa: F811
40+
def test_simple_ver1(server):
4141
# The dictionary in refs may be dumped with a different separator
4242
# depending on whether json or ujson is imported
4343
from fsspec.implementations.reference import json as json_impl
@@ -75,7 +75,7 @@ def test_target_options(m):
7575
assert fs.cat("a") == b"hello"
7676

7777

78-
def test_ls(server): # noqa: F811
78+
def test_ls(server):
7979
refs = {"a": b"data", "b": (realfile, 0, 5), "c/d": (realfile, 1, 6)}
8080
h = fsspec.filesystem("http")
8181
fs = fsspec.filesystem("reference", fo=refs, fs=h)
@@ -99,7 +99,7 @@ def test_nested_dirs_ls():
9999
assert {e["name"] for e in fs.ls("B")} == {"B/C", "B/_"}
100100

101101

102-
def test_info(server): # noqa: F811
102+
def test_info(server):
103103
refs = {
104104
"a": b"data",
105105
"b": (realfile, 0, 5),
@@ -173,7 +173,7 @@ def test_put_get_single(tmpdir):
173173
assert fs.cat("hi") == b"data"
174174

175175

176-
def test_defaults(server): # noqa: F811
176+
def test_defaults(server):
177177
refs = {"a": b"data", "b": (None, 0, 5)}
178178
fs = fsspec.filesystem(
179179
"reference",

fsspec/implementations/tests/test_smb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def smb_params(request):
5050
cfg = "-p -u 'testuser;testpass' -s 'home;/share;no;no;no;testuser'"
5151
port = request.param if request.param is not None else default_port
5252
img = (
53-
f"docker run --name {container} --detach -p 139:139 -p {port}:445 dperson/samba" # noqa: E231 E501
53+
f"docker run --name {container} --detach -p 139:139 -p {port}:445 dperson/samba"
5454
)
5555
cmd = f"{img} {cfg}"
5656
try:

fsspec/implementations/webhdfs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
if self._cached:
103103
return
104104
super().__init__(**kwargs)
105-
self.url = f"{'https' if use_https else 'http'}://{host}:{port}/webhdfs/v1" # noqa
105+
self.url = f"{'https' if use_https else 'http'}://{host}:{port}/webhdfs/v1"
106106
self.kerb = kerberos
107107
self.kerb_kwargs = kerb_kwargs or {}
108108
self.pars = {}
@@ -393,7 +393,7 @@ def cp_file(self, lpath, rpath, **kwargs):
393393
with self.open(tmp_fname, "wb") as rstream:
394394
shutil.copyfileobj(lstream, rstream)
395395
self.mv(tmp_fname, rpath)
396-
except BaseException: # noqa
396+
except BaseException:
397397
with suppress(FileNotFoundError):
398398
self.rm(tmp_fname)
399399
raise

fsspec/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1892,7 +1892,7 @@ def flush(self, force=False):
18921892
self.offset = 0
18931893
try:
18941894
self._initiate_upload()
1895-
except: # noqa: E722
1895+
except:
18961896
self.closed = True
18971897
raise
18981898

0 commit comments

Comments
 (0)