|
102 | 102 | ) |
103 | 103 |
|
104 | 104 | if not PD_LTE_23: |
105 | | - from pandas.errors import Pandas4Warning # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue,reportRedeclaration] # isort: skip |
| 105 | + from pandas.errors import Pandas4Warning # pyright: ignore[reportRedeclaration] |
106 | 106 | else: |
107 | 107 | Pandas4Warning: TypeAlias = FutureWarning # type: ignore[no-redef] |
108 | 108 |
|
@@ -387,7 +387,7 @@ def test_types_sort_values() -> None: |
387 | 387 | s = pd.Series([4, 2, 1, 3]) |
388 | 388 | check(assert_type(s.sort_values(), "pd.Series[int]"), pd.Series, np.integer) |
389 | 389 | if TYPE_CHECKING_INVALID_USAGE: |
390 | | - check(assert_type(s.sort_values(0), pd.Series), pd.Series) # type: ignore[assert-type,call-overload] # pyright: ignore[reportAssertTypeFailure,reportCallIssue] |
| 390 | + check(assert_type(s.sort_values(0), pd.Series), pd.Series) # type: ignore[assert-type,call-overload] # pyright: ignore[reportAssertTypeFailure,reportCallIssue,reportUnknownArgumentType] |
391 | 391 | check(assert_type(s.sort_values(axis=0), "pd.Series[int]"), pd.Series, np.integer) |
392 | 392 | check( |
393 | 393 | assert_type(s.sort_values(ascending=False), "pd.Series[int]"), |
@@ -859,7 +859,14 @@ def get_depth(url: str) -> int: |
859 | 859 | ss = s.astype(str) |
860 | 860 | check(assert_type(ss.apply(get_depth), pd.Series), pd.Series, np.integer) |
861 | 861 |
|
862 | | - check(assert_type(s.apply(lambda x: pd.NA), pd.Series), pd.Series, NAType) |
| 862 | + check( |
| 863 | + assert_type( |
| 864 | + s.apply(lambda x: pd.NA), # pyright: ignore[reportUnknownArgumentType] |
| 865 | + pd.Series, |
| 866 | + ), |
| 867 | + pd.Series, |
| 868 | + NAType, |
| 869 | + ) |
863 | 870 |
|
864 | 871 |
|
865 | 872 | def test_types_element_wise_arithmetic() -> None: |
@@ -923,7 +930,7 @@ def test_types_groupby() -> None: |
923 | 930 | s.groupby(s > 2) |
924 | 931 | # GH 284 |
925 | 932 | s.groupby([s > 2, s % 2 == 1]) |
926 | | - s.groupby(lambda x: x) |
| 933 | + s.groupby(lambda x: x) # pyright: ignore[reportUnknownArgumentType] |
927 | 934 | s.groupby([lambda x: x, lambda x: x.replace("a", "b")]) |
928 | 935 | s.groupby(np.array([1, 0, 1, 0])) |
929 | 936 | s.groupby([np.array([1, 0, 0, 0]), np.array([0, 0, 1, 0])]) |
@@ -1144,33 +1151,39 @@ def transform_func( |
1144 | 1151 |
|
1145 | 1152 | check( |
1146 | 1153 | assert_type( |
1147 | | - s.groupby(lambda x: x).transform(transform_func, True, kw_arg="foo"), |
| 1154 | + s.groupby( |
| 1155 | + lambda x: x # pyright: ignore[reportUnknownArgumentType] |
| 1156 | + ).transform(transform_func, True, kw_arg="foo"), |
1148 | 1157 | "pd.Series[float]", |
1149 | 1158 | ), |
1150 | 1159 | pd.Series, |
1151 | 1160 | float, |
1152 | 1161 | ) |
1153 | 1162 | check( |
1154 | 1163 | assert_type( |
1155 | | - s.groupby(lambda x: x).transform( |
1156 | | - transform_func, True, engine="cython", kw_arg="foo" |
1157 | | - ), |
| 1164 | + s.groupby( |
| 1165 | + lambda x: x # pyright: ignore[reportUnknownArgumentType] |
| 1166 | + ).transform(transform_func, True, engine="cython", kw_arg="foo"), |
1158 | 1167 | "pd.Series[float]", |
1159 | 1168 | ), |
1160 | 1169 | pd.Series, |
1161 | 1170 | float, |
1162 | 1171 | ) |
1163 | 1172 | check( |
1164 | 1173 | assert_type( |
1165 | | - s.groupby(lambda x: x).transform("mean"), |
1166 | | - "pd.Series", |
| 1174 | + s.groupby( |
| 1175 | + lambda x: x # pyright: ignore[reportUnknownArgumentType] |
| 1176 | + ).transform("mean"), |
| 1177 | + pd.Series, |
1167 | 1178 | ), |
1168 | 1179 | pd.Series, |
1169 | 1180 | ) |
1170 | 1181 | check( |
1171 | 1182 | assert_type( |
1172 | | - s.groupby(lambda x: x).transform("first"), |
1173 | | - "pd.Series", |
| 1183 | + s.groupby( |
| 1184 | + lambda x: x # pyright: ignore[reportUnknownArgumentType] |
| 1185 | + ).transform("first"), |
| 1186 | + pd.Series, |
1174 | 1187 | ), |
1175 | 1188 | pd.Series, |
1176 | 1189 | ) |
@@ -1429,7 +1442,12 @@ def test_types_rename_axis() -> None: |
1429 | 1442 | check(assert_type(s.rename_axis(index=["A"]), "pd.Series[int]"), pd.Series) |
1430 | 1443 | check(assert_type(s.rename_axis(index={"a": "A"}), "pd.Series[int]"), pd.Series) |
1431 | 1444 | check( |
1432 | | - assert_type(s.rename_axis(index=lambda name: name.upper()), "pd.Series[int]"), |
| 1445 | + assert_type( |
| 1446 | + s.rename_axis( |
| 1447 | + index=lambda name: name.upper() # pyright: ignore[reportUnknownArgumentType] |
| 1448 | + ), |
| 1449 | + "pd.Series[int]", |
| 1450 | + ), |
1433 | 1451 | pd.Series, |
1434 | 1452 | ) |
1435 | 1453 | check(assert_type(s.rename_axis(index=None), "pd.Series[int]"), pd.Series) |
@@ -3001,7 +3019,15 @@ def test_types_apply_set() -> None: |
3001 | 3019 | series_of_lists: pd.Series = pd.Series( |
3002 | 3020 | {"list1": [1, 2, 3], "list2": ["a", "b", "c"], "list3": [True, False, True]} |
3003 | 3021 | ) |
3004 | | - check(assert_type(series_of_lists.apply(lambda x: set(x)), pd.Series), pd.Series) |
| 3022 | + check( |
| 3023 | + assert_type( |
| 3024 | + series_of_lists.apply( |
| 3025 | + lambda x: set(x) # pyright: ignore[reportUnknownArgumentType] |
| 3026 | + ), |
| 3027 | + pd.Series, |
| 3028 | + ), |
| 3029 | + pd.Series, |
| 3030 | + ) |
3005 | 3031 |
|
3006 | 3032 |
|
3007 | 3033 | def test_prefix_summix_axis() -> None: |
@@ -3047,7 +3073,13 @@ def test_convert_dtypes_dtype_backend() -> None: |
3047 | 3073 | def test_apply_returns_none() -> None: |
3048 | 3074 | # GH 557 |
3049 | 3075 | s = pd.Series([1, 2, 3]) |
3050 | | - check(assert_type(s.apply(lambda x: None), pd.Series), pd.Series) |
| 3076 | + check( |
| 3077 | + assert_type( |
| 3078 | + s.apply(lambda x: None), # pyright: ignore[reportUnknownArgumentType] |
| 3079 | + pd.Series, |
| 3080 | + ), |
| 3081 | + pd.Series, |
| 3082 | + ) |
3051 | 3083 |
|
3052 | 3084 |
|
3053 | 3085 | def test_to_json_mode() -> None: |
@@ -3579,7 +3611,12 @@ def test_apply_dateoffset() -> None: |
3579 | 3611 | s = pd.Series(months) |
3580 | 3612 | check( |
3581 | 3613 | assert_type( |
3582 | | - s.apply(lambda x: pd.DateOffset(months=x)), "pd.Series[BaseOffset]" |
| 3614 | + s.apply( |
| 3615 | + lambda x: pd.DateOffset( |
| 3616 | + months=x # pyright: ignore[reportUnknownArgumentType] |
| 3617 | + ) |
| 3618 | + ), |
| 3619 | + "pd.Series[BaseOffset]", |
3583 | 3620 | ), |
3584 | 3621 | pd.Series, |
3585 | 3622 | pd.DateOffset, |
|
0 commit comments