Skip to content

Commit cbb6723

Browse files
authored
fix: Series initialiser also takes positional arguments (pandas-dev#1207)
* fix: Series initialiser also takes positional arguments * fix(comment): pandas-dev#1207 pandas-dev#1207 (comment) pandas-dev#1207 (comment) * fix: pandas-dev#1207 resume the order of arguments
1 parent fc331b1 commit cbb6723

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

pandas-stubs/core/series.pyi

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
246246
cls,
247247
data: npt.NDArray[np.float64],
248248
index: Axes | None = ...,
249-
*,
250249
dtype: Dtype = ...,
251250
name: Hashable = ...,
252251
copy: bool = ...,
@@ -256,7 +255,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
256255
cls,
257256
data: Sequence[Never],
258257
index: Axes | None = ...,
259-
*,
260258
dtype: Dtype = ...,
261259
name: Hashable = ...,
262260
copy: bool = ...,
@@ -266,7 +264,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
266264
cls,
267265
data: Sequence[list[str]],
268266
index: Axes | None = ...,
269-
*,
270267
dtype: Dtype = ...,
271268
name: Hashable = ...,
272269
copy: bool = ...,
@@ -276,7 +273,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
276273
cls,
277274
data: Sequence[str],
278275
index: Axes | None = ...,
279-
*,
280276
dtype: Dtype = ...,
281277
name: Hashable = ...,
282278
copy: bool = ...,
@@ -293,7 +289,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
293289
| date
294290
),
295291
index: Axes | None = ...,
296-
*,
297292
dtype: TimestampDtypeArg = ...,
298293
name: Hashable = ...,
299294
copy: bool = ...,
@@ -313,7 +308,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
313308
cls,
314309
data: PeriodIndex | Sequence[Period],
315310
index: Axes | None = ...,
316-
*,
317311
dtype: PeriodDtype = ...,
318312
name: Hashable = ...,
319313
copy: bool = ...,
@@ -329,7 +323,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
329323
| timedelta
330324
),
331325
index: Axes | None = ...,
332-
*,
333326
dtype: TimedeltaDtypeArg = ...,
334327
name: Hashable = ...,
335328
copy: bool = ...,
@@ -344,7 +337,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
344337
| dict[HashableT1, Interval[_OrderableT]]
345338
),
346339
index: Axes | None = ...,
347-
*,
348340
dtype: Literal["Interval"] = ...,
349341
name: Hashable = ...,
350342
copy: bool = ...,
@@ -364,7 +356,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
364356
cls,
365357
data: Sequence[bool],
366358
index: Axes | None = ...,
367-
*,
368359
dtype: Dtype = ...,
369360
name: Hashable = ...,
370361
copy: bool = ...,
@@ -374,7 +365,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
374365
cls,
375366
data: Sequence[int],
376367
index: Axes | None = ...,
377-
*,
378368
dtype: Dtype = ...,
379369
name: Hashable = ...,
380370
copy: bool = ...,
@@ -384,7 +374,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
384374
cls,
385375
data: Sequence[float],
386376
index: Axes | None = ...,
387-
*,
388377
dtype: Dtype = ...,
389378
name: Hashable = ...,
390379
copy: bool = ...,
@@ -394,7 +383,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
394383
cls,
395384
data: Sequence[int | float],
396385
index: Axes | None = ...,
397-
*,
398386
dtype: Dtype = ...,
399387
name: Hashable = ...,
400388
copy: bool = ...,
@@ -404,7 +392,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
404392
cls,
405393
data: S1 | _ListLike[S1] | dict[HashableT1, S1] | dict_keys[S1, Any],
406394
index: Axes | None = ...,
407-
*,
408395
dtype: Dtype = ...,
409396
name: Hashable = ...,
410397
copy: bool = ...,
@@ -422,7 +409,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
422409
| None
423410
) = ...,
424411
index: Axes | None = ...,
425-
*,
426412
dtype: Dtype = ...,
427413
name: Hashable = ...,
428414
copy: bool = ...,

tests/test_series.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ def test_types_init() -> None:
136136
pd.Series(data=groupby)
137137
pd.Series(data=resampler)
138138

139+
pd.Series([], pd.DatetimeIndex([]), float, "name")
140+
check(
141+
assert_type(pd.Series([1.0], pd.DatetimeIndex([1]), float), "pd.Series[float]"),
142+
pd.Series,
143+
float,
144+
)
145+
check(
146+
assert_type(pd.Series([1.0], pd.Index([1]), float, "f"), "pd.Series[float]"),
147+
pd.Series,
148+
float,
149+
)
150+
139151

140152
def test_types_any() -> None:
141153
check(assert_type(pd.Series([False, False]).any(), np.bool), np.bool)

0 commit comments

Comments
 (0)