Skip to content

Commit 0141d92

Browse files
authored
TYP: fix hashable keys for pd.concat (pandas-dev#46608)
1 parent 79fb2de commit 0141d92

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

pandas/_typing.py

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
else:
7474
npt: Any = None
7575

76+
HashableT = TypeVar("HashableT", bound=Hashable)
7677

7778
# array-like
7879

pandas/core/reshape/concat.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
import numpy as np
2020

21-
from pandas._typing import Axis
21+
from pandas._typing import (
22+
Axis,
23+
HashableT,
24+
)
2225
from pandas.util._decorators import (
2326
cache_readonly,
2427
deprecate_nonkeyword_arguments,
@@ -62,7 +65,7 @@
6265

6366
@overload
6467
def concat(
65-
objs: Iterable[DataFrame] | Mapping[Hashable, DataFrame],
68+
objs: Iterable[DataFrame] | Mapping[HashableT, DataFrame],
6669
axis: Literal[0, "index"] = ...,
6770
join: str = ...,
6871
ignore_index: bool = ...,
@@ -78,7 +81,7 @@ def concat(
7881

7982
@overload
8083
def concat(
81-
objs: Iterable[Series] | Mapping[Hashable, Series],
84+
objs: Iterable[Series] | Mapping[HashableT, Series],
8285
axis: Literal[0, "index"] = ...,
8386
join: str = ...,
8487
ignore_index: bool = ...,
@@ -94,7 +97,7 @@ def concat(
9497

9598
@overload
9699
def concat(
97-
objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame],
100+
objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame],
98101
axis: Literal[0, "index"] = ...,
99102
join: str = ...,
100103
ignore_index: bool = ...,
@@ -110,7 +113,7 @@ def concat(
110113

111114
@overload
112115
def concat(
113-
objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame],
116+
objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame],
114117
axis: Literal[1, "columns"],
115118
join: str = ...,
116119
ignore_index: bool = ...,
@@ -126,7 +129,7 @@ def concat(
126129

127130
@overload
128131
def concat(
129-
objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame],
132+
objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame],
130133
axis: Axis = ...,
131134
join: str = ...,
132135
ignore_index: bool = ...,
@@ -142,7 +145,7 @@ def concat(
142145

143146
@deprecate_nonkeyword_arguments(version=None, allowed_args=["objs"])
144147
def concat(
145-
objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame],
148+
objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame],
146149
axis: Axis = 0,
147150
join: str = "outer",
148151
ignore_index: bool = False,
@@ -367,7 +370,7 @@ class _Concatenator:
367370

368371
def __init__(
369372
self,
370-
objs: Iterable[NDFrame] | Mapping[Hashable, NDFrame],
373+
objs: Iterable[NDFrame] | Mapping[HashableT, NDFrame],
371374
axis=0,
372375
join: str = "outer",
373376
keys=None,

0 commit comments

Comments
 (0)