Skip to content

Commit a5a40a7

Browse files
authored
Make pandas.ExcelFile(...) in stubs consistent with the run time version. (#1117)
* Make `pd.ExcelFile` consistent with the run time. * Add test for the signature of `pd.ExcelFile`.
1 parent b5d6fea commit a5a40a7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pandas-stubs/io/excel/_base.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ class ExcelFile:
245245
io: FilePath | ReadBuffer[bytes] | bytes = ...
246246
def __init__(
247247
self,
248-
io: FilePath | ReadBuffer[bytes] | bytes,
248+
path_or_buffer: FilePath | ReadBuffer[bytes] | bytes,
249249
engine: ExcelReadEngine | None = ...,
250250
storage_options: StorageOptions = ...,
251+
engine_kwargs: dict[str, Any] | None = ...,
251252
) -> None: ...
252253
def __fspath__(self): ...
253254
@overload

tests/test_io.py

+8
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,14 @@ def test_excel_reader():
11161116
check(assert_type(ef, pd.ExcelFile), pd.ExcelFile)
11171117
check(assert_type(pd.read_excel(ef), pd.DataFrame), pd.DataFrame)
11181118

1119+
with pd.ExcelFile(
1120+
path_or_buffer=path,
1121+
engine="openpyxl",
1122+
engine_kwargs={"data_only": True},
1123+
) as ef:
1124+
check(assert_type(ef, pd.ExcelFile), pd.ExcelFile)
1125+
check(assert_type(pd.read_excel(ef), pd.DataFrame), pd.DataFrame)
1126+
11191127

11201128
def test_excel_writer():
11211129
with ensure_clean(".xlsx") as path:

0 commit comments

Comments
 (0)