File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,16 @@ class Series(IndexOpsMixin[S1], NDFrame):
241
241
copy : bool = ...,
242
242
) -> Series [float ]: ...
243
243
@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
244
254
def __new__ (
245
255
cls ,
246
256
data : (
Original file line number Diff line number Diff line change 7
7
Iterator ,
8
8
Mapping ,
9
9
MutableMapping ,
10
+ Sequence ,
10
11
)
11
12
import csv
12
13
import datetime
38
39
from pandas .core .series import Series
39
40
import pytest
40
41
from typing_extensions import (
42
+ Never ,
41
43
TypeAlias ,
42
44
assert_never ,
43
45
assert_type ,
@@ -3566,3 +3568,12 @@ class MyDict(TypedDict):
3566
3568
my_dict = MyDict (a = "" , b = "" )
3567
3569
sr = pd .Series (my_dict )
3568
3570
check (assert_type (sr , pd .Series ), pd .Series )
3571
+
3572
+
3573
+ def test_series_empty_dtype () -> None :
3574
+ """Test for the creation of a Series from an empty list GH571 to map to a Series[Any]."""
3575
+ new_tab : Sequence [Never ] = [] # need to be typehinted to please mypy
3576
+ check (assert_type (pd .Series (new_tab ), "pd.Series[Any]" ), pd .Series )
3577
+ check (assert_type (pd .Series ([]), "pd.Series[Any]" ), pd .Series )
3578
+ # ensure that an empty string does not get matched to Sequence[Never]
3579
+ check (assert_type (pd .Series ("" ), "pd.Series[str]" ), pd .Series )
You can’t perform that action at this time.
0 commit comments