1
1
"""Test module for classes in pandas.api.typing."""
2
2
3
- from typing import Literal # noqa: F401
4
- from typing import TYPE_CHECKING
5
-
6
3
import numpy as np
7
4
import pandas as pd
8
5
from pandas .api .typing import (
13
10
)
14
11
from typing_extensions import assert_type
15
12
16
- from pandas ._typing import Scalar # noqa: F401
17
-
18
13
from tests import check
19
14
20
- if TYPE_CHECKING :
21
- from pandas .core .groupby .groupby import _ResamplerGroupBy # noqa: F401
22
-
23
15
24
16
def test_dataframegroupby ():
25
17
df = pd .DataFrame ({"a" : [1 , 2 , 3 ]})
26
18
check (
27
- assert_type (df .groupby ("a" ), " DataFrameGroupBy[Scalar, Literal[True]]" ),
19
+ assert_type (df .groupby ("a" ), DataFrameGroupBy ),
28
20
DataFrameGroupBy ,
29
21
)
30
22
31
23
32
24
def test_seriesgroupby ():
33
25
sr : pd .Series [int ] = pd .Series ([1 , 2 , 3 ], index = pd .Index (["a" , "b" , "a" ]))
34
26
check (
35
- assert_type (sr .groupby (level = 0 ), " SeriesGroupBy[int, Scalar]" ),
27
+ assert_type (sr .groupby (level = 0 ), SeriesGroupBy ),
36
28
SeriesGroupBy ,
37
29
)
38
30
@@ -44,7 +36,7 @@ def tests_datetimeindexersamplergroupby() -> None:
44
36
)
45
37
gb_df = df .groupby ("col2" )
46
38
check (
47
- assert_type (gb_df .resample ("ME" ), "_ResamplerGroupBy[pd.DataFrame]" ),
39
+ assert_type (gb_df .resample ("ME" ), DatetimeIndexResamplerGroupby ),
48
40
DatetimeIndexResamplerGroupby ,
49
41
pd .DataFrame ,
50
42
)
0 commit comments