Skip to content

Commit a49dd63

Browse files
committed
TYP: quotechar, has_mi_columns, _need_to_save...
1 parent ba353a5 commit a49dd63

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pandas/io/formats/csvs.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
CompressionOptions,
1616
FilePathOrBuffer,
1717
IndexLabel,
18+
Label,
1819
StorageOptions,
1920
)
2021

@@ -44,7 +45,7 @@ def __init__(
4445
sep: str = ",",
4546
na_rep: str = "",
4647
float_format: Optional[str] = None,
47-
cols=None,
48+
cols: Optional[Sequence[Label]] = None,
4849
header: Union[bool, Sequence[Hashable]] = True,
4950
index: bool = True,
5051
index_label: IndexLabel = None,
@@ -55,7 +56,7 @@ def __init__(
5556
quoting: Optional[int] = None,
5657
line_terminator="\n",
5758
chunksize: Optional[int] = None,
58-
quotechar='"',
59+
quotechar: Optional[str] = '"',
5960
date_format: Optional[str] = None,
6061
doublequote: bool = True,
6162
escapechar: Optional[str] = None,
@@ -141,18 +142,19 @@ def _get_index_label_flat(self):
141142
return [""] if index_label is None else [index_label]
142143

143144
@property
144-
def quotechar(self):
145+
def quotechar(self) -> Optional[str]:
145146
if self.quoting != csvlib.QUOTE_NONE:
146147
# prevents crash in _csv
147148
return self._quotechar
149+
return None
148150

149151
@quotechar.setter
150-
def quotechar(self, quotechar):
152+
def quotechar(self, quotechar: Optional[str]) -> None:
151153
self._quotechar = quotechar
152154

153155
@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))
156158

157159
@property
158160
def cols(self):
@@ -178,7 +180,6 @@ def cols(self, cols):
178180
cols = self.obj.columns
179181
if isinstance(cols, ABCIndexClass):
180182
cols = cols.to_native_types(**self._number_format)
181-
182183
else:
183184
cols = list(cols)
184185

@@ -229,8 +230,8 @@ def _has_aliases(self):
229230
return isinstance(self.header, (tuple, list, np.ndarray, ABCIndexClass))
230231

231232
@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)
234235

235236
@property
236237
def write_cols(self):

0 commit comments

Comments
 (0)