Skip to content

Commit 5cba141

Browse files
committed
Rework _T_OBJECT
1 parent 1ae4b9e commit 5cba141

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

pandas-stubs/core/indexes/base.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class Index(IndexOpsMixin[S1]):
275275
Index[int],
276276
Index[bytes],
277277
Index[_str],
278-
Index[type[object]],
278+
Index,
279279
]: ...
280280
@final
281281
def is_(self, other) -> bool: ...

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
11811181
Series[int],
11821182
Series[bytes],
11831183
Series[_str],
1184-
Series[type[object]],
1184+
Series,
11851185
]: ...
11861186
@property
11871187
def dt(self) -> CombinedDatetimelikeProperties: ...

pandas-stubs/core/strings/accessor.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ _T_BYTES = TypeVar("_T_BYTES", bound=Series[bytes] | Index[bytes])
4747
# Used for the result of str.decode
4848
_T_STR = TypeVar("_T_STR", bound=Series[str] | Index[str])
4949
# Used for the result of str.partition
50-
_T_OBJECT = TypeVar("_T_OBJECT", bound=Series[type[object]] | Index[type[object]])
50+
_T_OBJECT = TypeVar("_T_OBJECT", bound=Series | Index)
5151

5252
class StringMethods(
5353
NoNewAttributesMixin,

tests/test_string_accessors.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,12 @@ def test_series_overloads_partition():
356356
assert_type(s.str.partition(sep=";", expand=True), pd.DataFrame), pd.DataFrame
357357
)
358358
check(
359-
assert_type(s.str.partition(sep=";", expand=False), "pd.Series[type[object]]"),
359+
assert_type(s.str.partition(sep=";", expand=False), pd.Series),
360360
pd.Series,
361361
object,
362362
)
363363
check(
364-
assert_type(s.str.partition(expand=False), "pd.Series[type[object]]"),
364+
assert_type(s.str.partition(expand=False), pd.Series),
365365
pd.Series,
366366
object,
367367
)
@@ -371,15 +371,11 @@ def test_series_overloads_partition():
371371
assert_type(s.str.rpartition(sep=";", expand=True), pd.DataFrame), pd.DataFrame
372372
)
373373
check(
374-
assert_type(s.str.rpartition(sep=";", expand=False), "pd.Series[type[object]]"),
375-
pd.Series,
376-
object,
377-
)
378-
check(
379-
assert_type(s.str.rpartition(expand=False), "pd.Series[type[object]]"),
374+
assert_type(s.str.rpartition(sep=";", expand=False), pd.Series),
380375
pd.Series,
381376
object,
382377
)
378+
check(assert_type(s.str.rpartition(expand=False), pd.Series), pd.Series, object)
383379

384380

385381
def test_index_overloads_partition():
@@ -400,7 +396,7 @@ def test_index_overloads_partition():
400396
pd.MultiIndex,
401397
)
402398
check(
403-
assert_type(idx.str.partition(sep=";", expand=False), "pd.Index[type[object]]"),
399+
assert_type(idx.str.partition(sep=";", expand=False), pd.Index),
404400
pd.Index,
405401
object,
406402
)
@@ -411,9 +407,7 @@ def test_index_overloads_partition():
411407
pd.MultiIndex,
412408
)
413409
check(
414-
assert_type(
415-
idx.str.rpartition(sep=";", expand=False), "pd.Index[type[object]]"
416-
),
410+
assert_type(idx.str.rpartition(sep=";", expand=False), pd.Index),
417411
pd.Index,
418412
object,
419413
)
@@ -490,16 +484,12 @@ def test_series_overloads_extract():
490484
assert_type(s.str.extract(r"[ab](\d)", expand=True), pd.DataFrame), pd.DataFrame
491485
)
492486
check(
493-
assert_type(
494-
s.str.extract(r"[ab](\d)", expand=False), "pd.Series[type[object]]"
495-
),
487+
assert_type(s.str.extract(r"[ab](\d)", expand=False), pd.Series),
496488
pd.Series,
497489
object,
498490
)
499491
check(
500-
assert_type(
501-
s.str.extract(r"[ab](\d)", re.IGNORECASE, False), "pd.Series[type[object]]"
502-
),
492+
assert_type(s.str.extract(r"[ab](\d)", re.IGNORECASE, False), pd.Series),
503493
pd.Series,
504494
object,
505495
)
@@ -513,16 +503,12 @@ def test_index_overloads_extract():
513503
pd.DataFrame,
514504
)
515505
check(
516-
assert_type(
517-
idx.str.extract(r"[ab](\d)", expand=False), "pd.Index[type[object]]"
518-
),
506+
assert_type(idx.str.extract(r"[ab](\d)", expand=False), pd.Index),
519507
pd.Index,
520508
object,
521509
)
522510
check(
523-
assert_type(
524-
idx.str.extract(r"[ab](\d)", re.IGNORECASE, False), "pd.Index[type[object]]"
525-
),
511+
assert_type(idx.str.extract(r"[ab](\d)", re.IGNORECASE, False), pd.Index),
526512
pd.Index,
527513
object,
528514
)

0 commit comments

Comments
 (0)