Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use IO[bytes] instead of BytesIO #18647

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading