From 79fea46ffc2abca193316a868ef8f4abbed9185a Mon Sep 17 00:00:00 2001 From: Andrea Ghensi Date: Sat, 30 Nov 2024 14:26:20 +0100 Subject: [PATCH 1/2] GH1061 add calamine literal to ExcelFile engine --- pandas-stubs/io/excel/_base.pyi | 2 +- tests/test_io.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pandas-stubs/io/excel/_base.pyi b/pandas-stubs/io/excel/_base.pyi index 21085daf4..f03bdd08b 100644 --- a/pandas-stubs/io/excel/_base.pyi +++ b/pandas-stubs/io/excel/_base.pyi @@ -246,7 +246,7 @@ class ExcelFile: def __init__( self, io: FilePath | ReadBuffer[bytes] | bytes, - engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = ..., + engine: ExcelReadEngine | None = ..., storage_options: StorageOptions = ..., ) -> None: ... def __fspath__(self): ... diff --git a/tests/test_io.py b/tests/test_io.py index 17c702d20..7c01a2b73 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1108,6 +1108,13 @@ def test_read_excel_dtypes(): dtypes = {"a": np.int64, "b": str, "c": np.float64} check(assert_type(read_excel(path, dtype=dtypes), pd.DataFrame), pd.DataFrame) +def test_excel_reader(): + with ensure_clean(".xlsx") as path: + check(assert_type(DF.to_excel(path), None), type(None)) + with pd.ExcelFile(path, engine="calamine") as ef: + check(assert_type(ef, pd.ExcelFile), pd.ExcelFile) + check(assert_type(pd.read_excel(ef), pd.DataFrame), pd.DataFrame) + def test_excel_writer(): with ensure_clean(".xlsx") as path: From 9725c605222eb327356c55f15aa9c9665903ecd6 Mon Sep 17 00:00:00 2001 From: Andrea Ghensi Date: Sat, 30 Nov 2024 17:17:33 +0100 Subject: [PATCH 2/2] fix format --- tests/test_io.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_io.py b/tests/test_io.py index 7c01a2b73..682798854 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1108,6 +1108,7 @@ def test_read_excel_dtypes(): dtypes = {"a": np.int64, "b": str, "c": np.float64} check(assert_type(read_excel(path, dtype=dtypes), pd.DataFrame), pd.DataFrame) + def test_excel_reader(): with ensure_clean(".xlsx") as path: check(assert_type(DF.to_excel(path), None), type(None))