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..682798854 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1109,6 +1109,14 @@ def test_read_excel_dtypes(): 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: with pd.ExcelWriter(path) as ew: