|
| 1 | +from builtins import str as _str |
1 | 2 | from typing import Any |
2 | 3 |
|
3 | 4 | import numpy as np |
|
10 | 11 |
|
11 | 12 |
|
12 | 13 | def test_add_py_scalar() -> None: |
13 | | - """Test pd.Series[str] + Python native str""" |
| 14 | + """Testpd.Series[str]+ Python native str""" |
14 | 15 | r0 = "right" |
15 | 16 |
|
16 | | - check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str) |
| 17 | + check(assert_type(left + r0, "pd.Series[_str]"), pd.Series, _str) |
17 | 18 |
|
18 | | - check(assert_type(r0 + left, "pd.Series[str]"), pd.Series, str) |
| 19 | + check(assert_type(r0 + left, "pd.Series[_str]"), pd.Series, _str) |
19 | 20 |
|
20 | | - check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str) |
| 21 | + check(assert_type(left.add(r0), "pd.Series[_str]"), pd.Series, _str) |
21 | 22 |
|
22 | | - check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str) |
| 23 | + check(assert_type(left.radd(r0), "pd.Series[_str]"), pd.Series, _str) |
23 | 24 |
|
24 | 25 |
|
25 | 26 | def test_add_py_sequence() -> None: |
26 | | - """Test pd.Series[str] + Python native sequence""" |
| 27 | + """Testpd.Series[str]+ Python native sequence""" |
27 | 28 | r0 = ["a", "bc", "def"] |
28 | 29 | r1 = tuple(r0) |
29 | 30 |
|
30 | | - check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str) |
31 | | - check(assert_type(left + r1, "pd.Series[str]"), pd.Series, str) |
| 31 | + check(assert_type(left + r0, "pd.Series[_str]"), pd.Series, _str) |
| 32 | + check(assert_type(left + r1, "pd.Series[_str]"), pd.Series, _str) |
32 | 33 |
|
33 | | - check(assert_type(r0 + left, "pd.Series[str]"), pd.Series, str) |
34 | | - check(assert_type(r1 + left, "pd.Series[str]"), pd.Series, str) |
| 34 | + check(assert_type(r0 + left, "pd.Series[_str]"), pd.Series, _str) |
| 35 | + check(assert_type(r1 + left, "pd.Series[_str]"), pd.Series, _str) |
35 | 36 |
|
36 | | - check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str) |
37 | | - check(assert_type(left.add(r1), "pd.Series[str]"), pd.Series, str) |
| 37 | + check(assert_type(left.add(r0), "pd.Series[_str]"), pd.Series, _str) |
| 38 | + check(assert_type(left.add(r1), "pd.Series[_str]"), pd.Series, _str) |
38 | 39 |
|
39 | | - check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str) |
40 | | - check(assert_type(left.radd(r1), "pd.Series[str]"), pd.Series, str) |
| 40 | + check(assert_type(left.radd(r0), "pd.Series[_str]"), pd.Series, _str) |
| 41 | + check(assert_type(left.radd(r1), "pd.Series[_str]"), pd.Series, _str) |
41 | 42 |
|
42 | 43 |
|
43 | 44 | def test_add_numpy_array() -> None: |
44 | | - """Test pd.Series[str] + numpy array""" |
| 45 | + """Testpd.Series[str]+ numpy array""" |
45 | 46 | r0 = np.array(["a", "bc", "def"], np.str_) |
46 | 47 |
|
47 | | - check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str) |
| 48 | + check(assert_type(left + r0, "pd.Series[_str]"), pd.Series, _str) |
48 | 49 |
|
49 | 50 | # `numpy` typing gives `Any` in the static type |
50 | 51 | # checking, where our `__radd__` cannot override. At runtime, they return |
51 | 52 | # `Series`s. |
52 | | - check(assert_type(r0 + left, Any), pd.Series, str) |
| 53 | + check(assert_type(r0 + left, Any), pd.Series, _str) |
53 | 54 |
|
54 | | - check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str) |
| 55 | + check(assert_type(left.add(r0), "pd.Series[_str]"), pd.Series, _str) |
55 | 56 |
|
56 | | - check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str) |
| 57 | + check(assert_type(left.radd(r0), "pd.Series[_str]"), pd.Series, _str) |
57 | 58 |
|
58 | 59 |
|
59 | 60 | def test_add_pd_series() -> None: |
60 | | - """Test pd.Series[str] + pandas series""" |
| 61 | + """Testpd.Series[str]+ pandas series""" |
61 | 62 | r0 = pd.Series(["a", "bc", "def"]) |
62 | 63 |
|
63 | | - check(assert_type(left + r0, "pd.Series[str]"), pd.Series, str) |
| 64 | + check(assert_type(left + r0, "pd.Series[_str]"), pd.Series, _str) |
64 | 65 |
|
65 | | - check(assert_type(r0 + left, "pd.Series[str]"), pd.Series, str) |
| 66 | + check(assert_type(r0 + left, "pd.Series[_str]"), pd.Series, _str) |
66 | 67 |
|
67 | | - check(assert_type(left.add(r0), "pd.Series[str]"), pd.Series, str) |
| 68 | + check(assert_type(left.add(r0), "pd.Series[_str]"), pd.Series, _str) |
68 | 69 |
|
69 | | - check(assert_type(left.radd(r0), "pd.Series[str]"), pd.Series, str) |
| 70 | + check(assert_type(left.radd(r0), "pd.Series[_str]"), pd.Series, _str) |
0 commit comments