Skip to content

Commit d8a8a73

Browse files
committed
fix: Series initialiser also takes positional arguments
1 parent fc331b1 commit d8a8a73

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

pandas-stubs/core/series.pyi

Lines changed: 2 additions & 18 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 = ...,
@@ -303,8 +298,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
303298
cls,
304299
data: _ListLike,
305300
index: Axes | None = ...,
306-
*,
307-
dtype: TimestampDtypeArg,
301+
dtype: TimestampDtypeArg = ...,
308302
name: Hashable = ...,
309303
copy: bool = ...,
310304
) -> TimestampSeries: ...
@@ -313,7 +307,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
313307
cls,
314308
data: PeriodIndex | Sequence[Period],
315309
index: Axes | None = ...,
316-
*,
317310
dtype: PeriodDtype = ...,
318311
name: Hashable = ...,
319312
copy: bool = ...,
@@ -329,7 +322,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
329322
| timedelta
330323
),
331324
index: Axes | None = ...,
332-
*,
333325
dtype: TimedeltaDtypeArg = ...,
334326
name: Hashable = ...,
335327
copy: bool = ...,
@@ -344,7 +336,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
344336
| dict[HashableT1, Interval[_OrderableT]]
345337
),
346338
index: Axes | None = ...,
347-
*,
348339
dtype: Literal["Interval"] = ...,
349340
name: Hashable = ...,
350341
copy: bool = ...,
@@ -354,8 +345,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
354345
cls,
355346
data: Scalar | _ListLike | dict[HashableT1, Any] | None,
356347
index: Axes | None = ...,
357-
*,
358-
dtype: type[S1],
348+
dtype: type[S1] = ...,
359349
name: Hashable = ...,
360350
copy: bool = ...,
361351
) -> Self: ...
@@ -364,7 +354,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
364354
cls,
365355
data: Sequence[bool],
366356
index: Axes | None = ...,
367-
*,
368357
dtype: Dtype = ...,
369358
name: Hashable = ...,
370359
copy: bool = ...,
@@ -374,7 +363,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
374363
cls,
375364
data: Sequence[int],
376365
index: Axes | None = ...,
377-
*,
378366
dtype: Dtype = ...,
379367
name: Hashable = ...,
380368
copy: bool = ...,
@@ -384,7 +372,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
384372
cls,
385373
data: Sequence[float],
386374
index: Axes | None = ...,
387-
*,
388375
dtype: Dtype = ...,
389376
name: Hashable = ...,
390377
copy: bool = ...,
@@ -394,7 +381,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
394381
cls,
395382
data: Sequence[int | float],
396383
index: Axes | None = ...,
397-
*,
398384
dtype: Dtype = ...,
399385
name: Hashable = ...,
400386
copy: bool = ...,
@@ -404,7 +390,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
404390
cls,
405391
data: S1 | _ListLike[S1] | dict[HashableT1, S1] | dict_keys[S1, Any],
406392
index: Axes | None = ...,
407-
*,
408393
dtype: Dtype = ...,
409394
name: Hashable = ...,
410395
copy: bool = ...,
@@ -422,7 +407,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
422407
| None
423408
) = ...,
424409
index: Axes | None = ...,
425-
*,
426410
dtype: Dtype = ...,
427411
name: Hashable = ...,
428412
copy: bool = ...,

tests/test_series.py

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

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

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

0 commit comments

Comments
 (0)