Skip to content

Commit d4947a9

Browse files
authored
TYP: alias IndexLabel without Optional (#36401)
1 parent a76f701 commit d4947a9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pandas/_typing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
Axis = Union[str, int]
8585
Label = Optional[Hashable]
86-
IndexLabel = Optional[Union[Label, Sequence[Label]]]
86+
IndexLabel = Union[Label, Sequence[Label]]
8787
Level = Union[Label, int]
8888
Ordered = Optional[bool]
8989
JSONSerializable = Optional[Union[PythonScalar, List, Dict]]

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3154,7 +3154,7 @@ def to_csv(
31543154
columns: Optional[Sequence[Label]] = None,
31553155
header: Union[bool_t, List[str]] = True,
31563156
index: bool_t = True,
3157-
index_label: IndexLabel = None,
3157+
index_label: Optional[IndexLabel] = None,
31583158
mode: str = "w",
31593159
encoding: Optional[str] = None,
31603160
compression: CompressionOptions = "infer",

pandas/io/formats/csvs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
cols: Optional[Sequence[Label]] = None,
4343
header: Union[bool, Sequence[Hashable]] = True,
4444
index: bool = True,
45-
index_label: IndexLabel = None,
45+
index_label: Optional[IndexLabel] = None,
4646
mode: str = "w",
4747
encoding: Optional[str] = None,
4848
errors: str = "strict",
@@ -100,7 +100,7 @@ def index_label(self) -> IndexLabel:
100100
return self._index_label
101101

102102
@index_label.setter
103-
def index_label(self, index_label: IndexLabel) -> None:
103+
def index_label(self, index_label: Optional[IndexLabel]) -> None:
104104
if index_label is not False:
105105
if index_label is None:
106106
index_label = self._get_index_label_from_obj()

0 commit comments

Comments
 (0)