Skip to content

Commit 01736d7

Browse files
GH571 Update typehint when creating a Series from an empty list
1 parent 8d9be32 commit 01736d7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pandas-stubs/core/series.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ class Series(IndexOpsMixin[S1], NDFrame):
241241
copy: bool = ...,
242242
) -> Series[float]: ...
243243
@overload
244+
def __new__( # type: ignore[overload-overlap]
245+
cls,
246+
data: Sequence[Never],
247+
index: Axes | None = ...,
248+
*,
249+
dtype: Dtype = ...,
250+
name: Hashable = ...,
251+
copy: bool = ...,
252+
) -> Series[Any]: ...
253+
@overload
244254
def __new__(
245255
cls,
246256
data: (

tests/test_frame.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Iterator,
88
Mapping,
99
MutableMapping,
10+
Sequence,
1011
)
1112
import csv
1213
import datetime
@@ -21,6 +22,7 @@
2122
Any,
2223
Callable,
2324
Generic,
25+
Never,
2426
TypedDict,
2527
TypeVar,
2628
Union,
@@ -3556,3 +3558,9 @@ class MyDict(TypedDict):
35563558
my_dict = MyDict(a="", b="")
35573559
sr = pd.Series(my_dict)
35583560
check(assert_type(sr, pd.Series), pd.Series)
3561+
3562+
3563+
def test_series_empty_dtype() -> None:
3564+
"""Test for the creation of a Series from an empty list GH571."""
3565+
new_tab: Sequence[Never] = []
3566+
check(assert_type(pd.Series(new_tab), "pd.Series[Any]"), pd.Series)

0 commit comments

Comments
 (0)