Skip to content

Commit

Permalink
Make pandas.ExcelFile(...) in stubs consistent with the run time ve…
Browse files Browse the repository at this point in the history
…rsion. (#1117)

* Make `pd.ExcelFile` consistent with the run time.

* Add test for the signature of `pd.ExcelFile`.
  • Loading branch information
cainmagi authored Feb 13, 2025
1 parent b5d6fea commit a5a40a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pandas-stubs/io/excel/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ class ExcelFile:
io: FilePath | ReadBuffer[bytes] | bytes = ...
def __init__(
self,
io: FilePath | ReadBuffer[bytes] | bytes,
path_or_buffer: FilePath | ReadBuffer[bytes] | bytes,
engine: ExcelReadEngine | None = ...,
storage_options: StorageOptions = ...,
engine_kwargs: dict[str, Any] | None = ...,
) -> None: ...
def __fspath__(self): ...
@overload
Expand Down
8 changes: 8 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,14 @@ def test_excel_reader():
check(assert_type(ef, pd.ExcelFile), pd.ExcelFile)
check(assert_type(pd.read_excel(ef), pd.DataFrame), pd.DataFrame)

with pd.ExcelFile(
path_or_buffer=path,
engine="openpyxl",
engine_kwargs={"data_only": True},
) 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:
Expand Down

0 comments on commit a5a40a7

Please sign in to comment.