Skip to content

Commit

Permalink
use IO[bytes] instead of BytesIO
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbe7a committed Sep 10, 2024
1 parent 5ccb238 commit d74341e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3638,7 +3638,7 @@ def write_ipc_stream(

def write_parquet(
self,
file: str | Path | BytesIO,
file: str | Path | IO[bytes],
*,
compression: ParquetCompression = "zstd",
compression_level: int | None = None,
Expand Down
12 changes: 12 additions & 0 deletions py-polars/tests/unit/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,3 +1891,15 @@ def test_concat_multiple_inmem() -> None:

assert_frame_equal(pl.read_parquet([fb, gb]), dfs)
assert_frame_equal(pl.read_parquet([fb, gb], use_pyarrow=True), dfs)

@pytest.mark.write_disk
def test_write_binary_open_file(tmp_path):
df = pl.DataFrame({"a": [1, 2, 3]})

path = tmp_path / "test.parquet"

with path.open("wb") as f_write:
df.write_parquet(f_write)

out = pl.read_parquet(path)
assert_frame_equal(out, df)

0 comments on commit d74341e

Please sign in to comment.