pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
29.22k stars 1.84k forks source link

Fix import of Worksheet from xlsxwriter #18450

Closed harrymconner closed 2 weeks ago

harrymconner commented 2 weeks ago

Checks

Reproducible example

# polars/dataframe/frame.py

from xlsxwriter import Workbook, Worksheet # Worksheet isn't exposed in xlsxwriter's __init__.py

from xlsxwriter.worksheet import Worksheet # Worksheet just needs to be imported from the worksheet module instead

Log output

N/A

Issue description

I noticed that pyright was complaining about all occurrences of df.write_excel() because the type of "Worksheet" was unknown. Looks like the Worksheet import in the frame.py module just needs to be imported from xlxswriter's worksheet module instead of the top level xlsxwriter namespace. Also, I'm happy to contribute this fix if needed!

Expected behavior

No pyright errors because it is able to resolve the import.

Installed versions

``` --------Version info--------- Polars: 1.6.0 Index type: UInt32 Platform: Windows-11-10.0.22631-SP0 Python: 3.12.5 (tags/v3.12.5:ff3bc82, Aug 6 2024, 20:45:27) [MSC v.1940 64 bit (AMD64)] ----Optional dependencies---- adbc_driver_manager altair cloudpickle connectorx 0.3.3 deltalake fastexcel fsspec gevent great_tables matplotlib nest_asyncio numpy 2.1.0 openpyxl pandas pyarrow pydantic pyiceberg sqlalchemy torch xlsx2csv xlsxwriter 3.2.0 ```
alexander-beedie commented 2 weeks ago

"Oops..." Thanks for the eagle-eyes on that one ;)