Skip to content

Commit b12acc1

Browse files
authored
Change ExcelWriter modes to {"w","a"} (#358)
* Change ExcelWriter modes to {"w","a") * New test for ExcelWriter append mode * Simplify test
1 parent cb56bfa commit b12acc1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas-stubs/io/excel/_base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ExcelWriter:
107107
engine: Literal["auto", "openpyxl", "pyxlsb", "odf"] | None = ...,
108108
date_format: str | None = ...,
109109
datetime_format: str | None = ...,
110-
mode: Literal["w", "writer"] = ...,
110+
mode: Literal["w", "a"] = ...,
111111
storage_options: StorageOptions = ...,
112112
if_sheet_exists: Literal["error", "new", "replace", "overlay"] | None = ...,
113113
engine_kwargs: dict[str, Any] | None = ...,

tests/test_io.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,14 @@ def test_excel_writer():
672672
check(assert_type(ef.close(), None), type(None))
673673

674674

675+
def test_excel_writer_append_mode():
676+
with ensure_clean(".xlsx") as path:
677+
with pd.ExcelWriter(path, mode="w") as ew:
678+
DF.to_excel(ew, sheet_name="A")
679+
with pd.ExcelWriter(path, mode="a") as ew:
680+
pass
681+
682+
675683
def test_to_string():
676684
check(assert_type(DF.to_string(), str), str)
677685
with ensure_clean() as path:

0 commit comments

Comments
 (0)