diff --git a/fsspec/implementations/arrow.py b/fsspec/implementations/arrow.py index 4c1d7d206..2cd6dc6b1 100644 --- a/fsspec/implementations/arrow.py +++ b/fsspec/implementations/arrow.py @@ -223,7 +223,6 @@ def get_file(self, rpath, lpath, **kwargs): "readable", "writable", "close", - "size", "seekable", ], ) @@ -241,6 +240,10 @@ def __init__(self, fs, stream, path, mode, block_size=None, **kwargs): def __enter__(self): return self + @property + def size(self): + return self.stream.size() + def __exit__(self, *args): return self.close() diff --git a/fsspec/implementations/tests/test_arrow.py b/fsspec/implementations/tests/test_arrow.py index edf48eb6d..e0e3e650a 100644 --- a/fsspec/implementations/tests/test_arrow.py +++ b/fsspec/implementations/tests/test_arrow.py @@ -280,9 +280,8 @@ def test_get_file_seekable_default(fs, remote_dir, tmp_path): # Test default behavior (seekable=False) local_file = tmp_path / "test_default.txt" - fs.get_file(remote_dir + "/test_file.txt", str(local_file)) - with open(local_file, "rb") as f: - assert f.read() == data + with pytest.raises(OSError, match="only valid on seekable files"): + fs.get_file(remote_dir + "/test_file.txt", str(local_file)) # Test with explicit seekable=True local_file_seekable = tmp_path / "test_seekable.txt" @@ -292,11 +291,10 @@ def test_get_file_seekable_default(fs, remote_dir, tmp_path): # Test with explicit seekable=False local_file_not_seekable = tmp_path / "test_not_seekable.txt" - fs.get_file( - remote_dir + "/test_file.txt", str(local_file_not_seekable), seekable=False - ) - with open(local_file_not_seekable, "rb") as f: - assert f.read() == data + with pytest.raises(OSError, match="only valid on seekable files"): + fs.get_file( + remote_dir + "/test_file.txt", str(local_file_not_seekable), seekable=False + ) def test_cat_file_seekable_override(fs, remote_dir): @@ -333,7 +331,7 @@ def test_seekable_true_allows_size_method(fs, remote_dir): with fs.open(test_file, "rb", seekable=True) as f: assert f.seekable() is True # Verify size() method works and returns correct size - file_size = f.size() + file_size = f.size assert file_size == len(data) # Also verify we can read the data assert f.read() == data @@ -353,6 +351,6 @@ def test_seekable_false_prevents_size_method(fs, remote_dir): assert f.seekable() is False # Verify size() raises OSError with pytest.raises(OSError, match="only valid on seekable files"): - f.size() + _ = f.size # Verify we can still read the data assert f.read() == data