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):
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 : (
Original file line number Diff line number Diff line change 77 Iterator ,
88 Mapping ,
99 MutableMapping ,
10+ Sequence ,
1011)
1112import csv
1213import datetime
3839from pandas .core .series import Series
3940import pytest
4041from typing_extensions import (
42+ Never ,
4143 TypeAlias ,
4244 assert_never ,
4345 assert_type ,
@@ -3566,3 +3568,12 @@ class MyDict(TypedDict):
35663568 my_dict = MyDict (a = "" , b = "" )
35673569 sr = pd .Series (my_dict )
35683570 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