22
22
except ImportError :
23
23
Workbook = Type
24
24
25
-
26
- from polars .type_aliases import (
27
- ColumnFormatDict ,
28
- ColumnTotalsDefinition ,
29
- ColumnWidthsDefinition ,
30
- ConditionalFormatDict ,
31
- OneOrMoreDataTypes ,
32
- RowTotalsDefinition ,
33
- SelectorType ,
34
- )
35
-
36
25
try :
37
26
import polars as pl
38
27
from polars import PolarsDataType
@@ -633,18 +622,32 @@ class PolarsSpreadsheetWriter(DataSaver):
633
622
Should map to https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.DataFrame.write_excel.html
634
623
"""
635
624
625
+ # importing here because this is where it's used. Can move later.
626
+ # but yeah the polars type aliases weren't resolving well in python 3.9
627
+ # so stripped/reduced them appropriately.
628
+ from polars .datatypes import DataType , DataTypeClass
629
+ from polars .type_aliases import ColumnTotalsDefinition , RowTotalsDefinition
630
+
636
631
workbook : Union [Workbook , BytesIO , Path , str ]
637
632
worksheet : Union [str , None ] = None
638
633
# kwargs:
639
634
position : Union [Tuple [int , int ], str ] = "A1"
640
635
table_style : Union [str , Dict [str , Any ], None ] = None
641
636
table_name : Union [str , None ] = None
642
- column_formats : Union [ColumnFormatDict , None ] = None
643
- dtype_formats : Union [Dict [OneOrMoreDataTypes , str ], None ] = None
644
- conditional_formats : Union [ConditionalFormatDict , None ] = None
637
+ column_formats : Union [
638
+ Mapping [Union [str , Tuple [str , ...]], Union [str , Mapping [str , str ]]], None
639
+ ] = None
640
+ dtype_formats : Union [Dict [Union [DataType , DataTypeClass ], str ], None ] = None
641
+ conditional_formats : Union [
642
+ Mapping [
643
+ Union [str , Collection [str ]],
644
+ Union [str , Union [Mapping [str , Any ], Sequence [Union [str , Mapping [str , Any ]]]]],
645
+ ],
646
+ None ,
647
+ ] = None
645
648
header_format : Union [Dict [str , Any ], None ] = None
646
649
column_totals : Union [ColumnTotalsDefinition , None ] = None
647
- column_widths : Union [ColumnWidthsDefinition , None ] = None
650
+ column_widths : Union [Mapping [ str , Union [ Tuple [ str , ...], int ]], int , None ] = None
648
651
row_totals : Union [RowTotalsDefinition , None ] = None
649
652
row_heights : Union [Dict [Union [int , Tuple [int , ...]], int ], int , None ] = None
650
653
sparklines : Union [Dict [str , Union [Sequence [str ], Dict [str , Any ]]], None ] = None
@@ -653,7 +656,7 @@ class PolarsSpreadsheetWriter(DataSaver):
653
656
include_header : bool = True
654
657
autofilter : bool = True
655
658
autofit : bool = False
656
- hidden_columns : Union [Sequence [str ], SelectorType , None ] = None
659
+ hidden_columns : Union [Sequence [str ], str , None ] = None
657
660
hide_gridlines : bool = None
658
661
sheet_zoom : Union [int , None ] = None
659
662
freeze_panes : Union [
0 commit comments