Skip to content

Commit 6ac55a7

Browse files
authored
Merge branch 'fsspec:master' into master
2 parents 23807ed + 8be05fc commit 6ac55a7

21 files changed

+59
-49
lines changed

fsspec/asyn.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -816,11 +816,9 @@ async def _glob(self, path, maxdepth=None, **kwargs):
816816
p: info
817817
for p, info in sorted(allpaths.items())
818818
if pattern.match(
819-
(
820-
p + "/"
821-
if append_slash_to_dirname and info["type"] == "directory"
822-
else p
823-
)
819+
p + "/"
820+
if append_slash_to_dirname and info["type"] == "directory"
821+
else p
824822
)
825823
}
826824

fsspec/caching.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import os
88
import threading
99
import warnings
10+
from concurrent.futures import Future, ThreadPoolExecutor
1011
from itertools import groupby
1112
from operator import itemgetter
12-
from concurrent.futures import Future, ThreadPoolExecutor
1313
from typing import (
1414
TYPE_CHECKING,
1515
Any,
@@ -87,12 +87,7 @@ def _log_stats(self) -> str:
8787
if self.hit_count == 0 and self.miss_count == 0:
8888
# a cache that does nothing, this is for logs only
8989
return ""
90-
return " , %s: %d hits, %d misses, %d total requested bytes" % (
91-
self.name,
92-
self.hit_count,
93-
self.miss_count,
94-
self.total_requested_bytes,
95-
)
90+
return f" , {self.name}: {self.hit_count} hits, {self.miss_count} misses, {self.total_requested_bytes} total requested bytes"
9691

9792
def __repr__(self) -> str:
9893
# TODO: use rich for better formatting

fsspec/core.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,7 @@ def get_fs_token_paths(
680680
elif not isinstance(paths, list):
681681
paths = list(paths)
682682
else:
683-
if "w" in mode and expand:
684-
paths = _expand_paths(paths, name_function, num)
685-
elif "x" in mode and expand:
683+
if ("w" in mode or "x" in mode) and expand:
686684
paths = _expand_paths(paths, name_function, num)
687685
elif "*" in paths:
688686
paths = [f for f in sorted(fs.glob(paths)) if not fs.isdir(f)]

fsspec/implementations/asyn_wrapper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
2-
import inspect
32
import functools
3+
import inspect
4+
45
from fsspec.asyn import AsyncFileSystem
56

67

fsspec/implementations/cached.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def cat(
612612
**kwargs,
613613
):
614614
paths = self.expand_path(
615-
path, recursive=recursive, maxdepth=kwargs.get("maxdepth", None)
615+
path, recursive=recursive, maxdepth=kwargs.get("maxdepth")
616616
)
617617
getpaths = []
618618
storepaths = []

fsspec/implementations/ftp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def _mlsd2(ftp, path="."):
387387
"size": split_line[4],
388388
},
389389
)
390-
if "d" == this[1]["unix.mode"][0]:
390+
if this[1]["unix.mode"][0] == "d":
391391
this[1]["type"] = "dir"
392392
else:
393393
this[1]["type"] = "file"

fsspec/implementations/reference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import logging
66
import math
77
import os
8-
from itertools import chain
98
from functools import lru_cache
9+
from itertools import chain
1010
from typing import TYPE_CHECKING, Literal
1111

1212
import fsspec.core
@@ -176,7 +176,7 @@ def open_refs(field, record):
176176
try:
177177
df = self.pd.read_parquet(data, engine=self.engine)
178178
refs = {c: df[c].to_numpy() for c in df.columns}
179-
except IOError:
179+
except OSError:
180180
refs = None
181181
return refs
182182

@@ -431,7 +431,7 @@ def write(self, field, record, base_url=None, storage_options=None):
431431
if len(partition) < self.record_size:
432432
try:
433433
original = self.open_refs(field, record)
434-
except IOError:
434+
except OSError:
435435
pass
436436

437437
if original:

fsspec/implementations/tests/test_asyn_wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import asyncio
2-
import pytest
32
import os
43

4+
import pytest
5+
56
import fsspec
67
from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper
78
from fsspec.implementations.local import LocalFileSystem
9+
810
from .test_local import csv_files, filetexts
911

1012

fsspec/implementations/tests/test_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def test_not_found():
247247
def test_isfile():
248248
fs = LocalFileSystem()
249249
with filetexts(files, mode="b"):
250-
for f in files.keys():
250+
for f in files:
251251
assert fs.isfile(f)
252252
assert fs.isfile(f"file://{f}")
253253
assert not fs.isfile("not-a-file")
@@ -257,7 +257,7 @@ def test_isfile():
257257
def test_isdir():
258258
fs = LocalFileSystem()
259259
with filetexts(files, mode="b"):
260-
for f in files.keys():
260+
for f in files:
261261
assert fs.isdir(os.path.dirname(os.path.abspath(f)))
262262
assert not fs.isdir(f)
263263
assert not fs.isdir("not-a-dir")

fsspec/implementations/tests/test_smb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
def stop_docker(container):
32-
cmd = shlex.split('docker ps -a -q --filter "name=%s"' % container)
32+
cmd = shlex.split(f'docker ps -a -q --filter "name={container}"')
3333
cid = subprocess.check_output(cmd).strip().decode()
3434
if cid:
3535
subprocess.call(["docker", "rm", "-f", "-v", cid])

0 commit comments

Comments
 (0)