Skip to content

Commit ca848bb

Browse files
committed
TYP: fix a few errors found by pandas-stub
1 parent 8ce4f29 commit ca848bb

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

pandas/_testing/asserters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ def assert_series_equal(
864864
check_dtype: bool | Literal["equiv"] = True,
865865
check_index_type="equiv",
866866
check_series_type=True,
867-
check_less_precise=no_default,
867+
check_less_precise: bool | int | NoDefault = no_default,
868868
check_names=True,
869869
check_exact=False,
870870
check_datetimelike_compat=False,

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ def _rename(
10501050
return result.__finalize__(self, method="rename")
10511051

10521052
@rewrite_axis_style_signature("mapper", [("copy", True), ("inplace", False)])
1053-
def rename_axis(self, mapper=lib.no_default, **kwargs):
1053+
def rename_axis(self, mapper: IndexLabel = lib.no_default, **kwargs):
10541054
"""
10551055
Set the name of the axis for the index or columns.
10561056

pandas/core/groupby/groupby.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4050,7 +4050,12 @@ def _reindex_output(
40504050
# "ndarray[Any, dtype[floating[_64Bit]]]"; expected "Index"
40514051
levels_list.append(qs) # type: ignore[arg-type]
40524052
names = names + [None]
4053-
index, _ = MultiIndex.from_product(levels_list, names=names).sortlevel()
4053+
# error: Argument "names" to "from_product" of "MultiIndex" has
4054+
# incompatible type "List[Hashable]"; expected "Union[Sequence[
4055+
# Optional[str]], Literal[_NoDefault.no_default]]"
4056+
index, _ = MultiIndex.from_product(
4057+
levels_list, names=names # type: ignore[arg-type]
4058+
).sortlevel()
40544059

40554060
if self.as_index:
40564061
# Always holds for SeriesGroupBy unless GH#36507 is implemented

pandas/core/indexes/multi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,10 @@ def from_tuples(
578578

579579
@classmethod
580580
def from_product(
581-
cls, iterables, sortorder=None, names=lib.no_default
581+
cls,
582+
iterables: Sequence[Iterable[Hashable]],
583+
sortorder: int | None = None,
584+
names: Sequence[str | None] | lib.NoDefault = lib.no_default,
582585
) -> MultiIndex:
583586
"""
584587
Make a MultiIndex from the cartesian product of multiple iterables.

pandas/plotting/_matplotlib/groupby.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ def reconstruct_data_with_by(
112112

113113
data_list = []
114114
for key, group in grouped:
115-
columns = MultiIndex.from_product([[key], cols])
115+
# error: List item 1 has incompatible type "Union[Hashable,
116+
# Sequence[Hashable]]"; expected "Iterable[Hashable]"
117+
columns = MultiIndex.from_product([[key], cols]) # type: ignore[list-item]
116118
sub_group = group[cols]
117119
sub_group.columns = columns
118120
data_list.append(sub_group)

0 commit comments

Comments
 (0)