Skip to content

Make pandas.ExcelFile(...) in stubs consistent with the run time version. #1117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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