Skip to content

Commit 56c44fc

Browse files
committed
Revert removing the mode from open()
1 parent fdecd1f commit 56c44fc

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

fsspec/implementations/cache_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, storage: list[str]):
5555
def _load(self, fn: str) -> Detail:
5656
"""Low-level function to load metadata from specific file"""
5757
try:
58-
with open(fn) as f:
58+
with open(fn, "r") as f:
5959
loaded = json.load(f)
6060
except ValueError:
6161
with open(fn, "rb") as f:

fsspec/implementations/tests/test_cached.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def test_metadata_replace_pickle_with_json(tmpdir):
185185
assert f.read(5) == b"test"
186186

187187
# Confirm metadata is in json format
188-
with open(cache_fn) as f:
188+
with open(cache_fn, "r") as f:
189189
metadata = json.load(f)
190190
assert list(metadata.keys()) == [make_path_posix(afile)]
191191

@@ -253,7 +253,7 @@ def test_blockcache_workflow(ftp_writable, tmp_path, force_save_pickle):
253253
with open(tmp_path / "cache", "rb") as f:
254254
cache = pickle.load(f)
255255
else:
256-
with open(tmp_path / "cache") as f:
256+
with open(tmp_path / "cache", "r") as f:
257257
cache = json.load(f)
258258
assert "/out" in cache
259259
assert cache["/out"]["blocks"] == [0, 1]
@@ -370,7 +370,7 @@ def __ager(cache_fn, fn, del_fn=False):
370370
with open(cache_fn, "rb") as f:
371371
cached_files = pickle.load(f)
372372
else:
373-
with open(cache_fn) as f:
373+
with open(cache_fn, "r") as f:
374374
cached_files = json.load(f)
375375
fn_posix = pathlib.Path(fn).as_posix()
376376
cached_files[fn_posix]["time"] = cached_files[fn_posix]["time"] - 691200

fsspec/implementations/tests/test_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def repo():
2424
open(os.path.join(d, "file1"), "wb").write(b"data0")
2525
subprocess.call("git add file1", shell=True, cwd=d)
2626
subprocess.call('git commit -m "init"', shell=True, cwd=d)
27-
sha = open(os.path.join(d, ".git/refs/heads/master")).read().strip()
27+
sha = open(os.path.join(d, ".git/refs/heads/master"), "r").read().strip()
2828
open(os.path.join(d, "file1"), "wb").write(b"data00")
2929
subprocess.check_output('git commit -a -m "tagger"', shell=True, cwd=d)
3030
subprocess.call('git tag -a thetag -m "make tag"', shell=True, cwd=d)

fsspec/tests/test_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,14 @@ def test_open_file_write_with_special_characters(tmp_path, char, monkeypatch):
304304
with fsspec.open(file_path, "w", expand=False) as f:
305305
f.write(expected_content)
306306

307-
with open(file_path) as f:
307+
with open(file_path, "r") as f:
308308
actual_content = f.read()
309309

310310
monkeypatch.setattr(fsspec.core, "DEFAULT_EXPAND", False)
311311
with fsspec.open(file_path, "w") as f:
312312
f.write(expected_content * 2)
313313

314-
with open(file_path) as f:
314+
with open(file_path, "r") as f:
315315
assert f.read() == actual_content * 2
316316

317317
assert actual_content == expected_content
@@ -347,7 +347,7 @@ def test_open_files_write_with_special_characters(tmp_path, char):
347347
)[0] as f:
348348
f.write(expected_content)
349349

350-
with open(file_path) as f:
350+
with open(file_path, "r") as f:
351351
actual_content = f.read()
352352

353353
assert actual_content == expected_content

fsspec/tests/test_fuse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_seek_rw(mount_local):
139139
fh.write("st")
140140
fh.close()
141141

142-
fh = open(mount_dir / "text")
142+
fh = open(mount_dir / "text", "r")
143143
assert fh.read() == "test"
144144
fh.seek(2)
145145
assert fh.read() == "st"

0 commit comments

Comments
 (0)