15
15
CompressionOptions ,
16
16
FilePathOrBuffer ,
17
17
IndexLabel ,
18
+ Label ,
18
19
StorageOptions ,
19
20
)
20
21
@@ -44,7 +45,7 @@ def __init__(
44
45
sep : str = "," ,
45
46
na_rep : str = "" ,
46
47
float_format : Optional [str ] = None ,
47
- cols = None ,
48
+ cols : Optional [ Sequence [ Label ]] = None ,
48
49
header : Union [bool , Sequence [Hashable ]] = True ,
49
50
index : bool = True ,
50
51
index_label : IndexLabel = None ,
@@ -55,7 +56,7 @@ def __init__(
55
56
quoting : Optional [int ] = None ,
56
57
line_terminator = "\n " ,
57
58
chunksize : Optional [int ] = None ,
58
- quotechar = '"' ,
59
+ quotechar : Optional [ str ] = '"' ,
59
60
date_format : Optional [str ] = None ,
60
61
doublequote : bool = True ,
61
62
escapechar : Optional [str ] = None ,
@@ -141,18 +142,19 @@ def _get_index_label_flat(self):
141
142
return ["" ] if index_label is None else [index_label ]
142
143
143
144
@property
144
- def quotechar (self ):
145
+ def quotechar (self ) -> Optional [ str ] :
145
146
if self .quoting != csvlib .QUOTE_NONE :
146
147
# prevents crash in _csv
147
148
return self ._quotechar
149
+ return None
148
150
149
151
@quotechar .setter
150
- def quotechar (self , quotechar ) :
152
+ def quotechar (self , quotechar : Optional [ str ]) -> None :
151
153
self ._quotechar = quotechar
152
154
153
155
@property
154
- def has_mi_columns (self ):
155
- return isinstance (self .obj .columns , ABCMultiIndex )
156
+ def has_mi_columns (self ) -> bool :
157
+ return bool ( isinstance (self .obj .columns , ABCMultiIndex ) )
156
158
157
159
@property
158
160
def cols (self ):
@@ -178,7 +180,6 @@ def cols(self, cols):
178
180
cols = self .obj .columns
179
181
if isinstance (cols , ABCIndexClass ):
180
182
cols = cols .to_native_types (** self ._number_format )
181
-
182
183
else :
183
184
cols = list (cols )
184
185
@@ -229,8 +230,8 @@ def _has_aliases(self):
229
230
return isinstance (self .header , (tuple , list , np .ndarray , ABCIndexClass ))
230
231
231
232
@property
232
- def _need_to_save_header (self ):
233
- return self ._has_aliases or self .header
233
+ def _need_to_save_header (self ) -> bool :
234
+ return bool ( self ._has_aliases or self .header )
234
235
235
236
@property
236
237
def write_cols (self ):
0 commit comments