Skip to content

Commit c118810

Browse files
GH1248/GH1249 PR feedback
1 parent 286dfb1 commit c118810

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

pandas-stubs/_typing.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,8 @@ IntoColumn: TypeAlias = (
10161016
AnyArrayLike
10171017
| Scalar
10181018
| Callable[[DataFrame], AnyArrayLike | Scalar | list[Scalar] | range]
1019+
| list[Scalar]
1020+
| range
10191021
| None
10201022
)
10211023

tests/test_frame.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
)
4646
import xarray as xr
4747

48-
from pandas._typing import Scalar
48+
from pandas._typing import (
49+
Scalar,
50+
)
4951

5052
from tests import (
5153
PD_LTE_23,
@@ -315,11 +317,15 @@ def test_types_assign() -> None:
315317
df = pd.DataFrame({"a": [1, 2, 3]})
316318
check(
317319
assert_type(
318-
df.assign(b=lambda df: range(len(df)), c=lambda df: [10, 20, 30]),
320+
df.assign(b=lambda df: range(len(df)), c=lambda _: [10, 20, 30]),
319321
pd.DataFrame,
320322
),
321323
pd.DataFrame,
322324
)
325+
check(
326+
assert_type(df.assign(b=range(len(df)), c=[10, 20, 30]), pd.DataFrame),
327+
pd.DataFrame,
328+
)
323329

324330

325331
def test_assign() -> None:

tests/test_indexes.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,18 @@ def test_index_astype() -> None:
6262
)
6363

6464
df = pd.DataFrame({"a": [1, 2, 3]})
65-
mi = pd.MultiIndex.from_product([["x", "y"], df.columns])
66-
mi = pd.MultiIndex.from_product([["x", "y"], pd.Series([1, 2])])
65+
check(
66+
assert_type(
67+
pd.MultiIndex.from_product([["x", "y"], df.columns]), pd.MultiIndex
68+
),
69+
pd.MultiIndex,
70+
)
71+
check(
72+
assert_type(
73+
pd.MultiIndex.from_product([["x", "y"], pd.Series([1, 2])]), pd.MultiIndex
74+
),
75+
pd.MultiIndex,
76+
)
6777

6878

6979
def test_multiindex_get_level_values() -> None:

0 commit comments

Comments
 (0)