@@ -36,6 +36,8 @@ This also allows type checking for operations on series that contain date/time d
36
36
the following example that creates two series of datetimes with corresponding arithmetic.
37
37
38
38
``` python
39
+ import pandas as pd
40
+
39
41
s1 = pd.Series(pd.to_datetime([" 2022-05-01" , " 2022-06-01" ]))
40
42
reveal_type(s1)
41
43
s2 = pd.Series(pd.to_datetime([" 2022-05-15" , " 2022-06-15" ]))
@@ -46,19 +48,21 @@ ssum = s1 + s2
46
48
reveal_type(ssum)
47
49
```
48
50
49
- The above code (without the ` reveal_type() ` statements) will raise an ` Exception ` on the computation of ` ssum ` because it is
51
+ The above code (without the ` reveal_type() ` statements) will get a ` Never `
52
+ on the computation of ` ssum ` because it is
50
53
inappropriate to add two series containing ` Timestamp ` values. The types will be
51
54
revealed as follows:
52
55
53
56
``` text
54
- ttest.py:4: note: Revealed type is "pandas.core.series.TimestampSeries "
55
- ttest.py:6: note: Revealed type is "pandas.core.series.TimestampSeries "
57
+ ttest.py:4: note: Revealed type is "pandas.core.series.Series[pandas._libs.tslibs.timestamps.Timestamp] "
58
+ ttest.py:6: note: Revealed type is "pandas.core.series.Series[pandas._libs.tslibs.timestamps.Timestamp] "
56
59
ttest.py:8: note: Revealed type is "pandas.core.series.TimedeltaSeries"
57
- ttest.py:10: note: Revealed type is "builtins.Exception"
60
+ ttest.py:9: error: Need type annotation for "ssum" [var-annotated]
61
+ ttest.py:10: note: Revealed type is "Never"
58
62
```
59
63
60
- The type ` TimestampSeries ` is the result of creating a series from ` pd.to_datetime() ` , while
61
- the type ` TimedeltaSeries ` is the result of subtracting two ` TimestampSeries ` as well as
64
+ The type ` Series[Timestamp] ` is the result of creating a series from ` pd.to_datetime() ` , while
65
+ the type ` TimedeltaSeries ` is the result of subtracting two ` Series[Timestamp] ` as well as
62
66
the result of ` pd.to_timedelta() ` .
63
67
64
68
### Interval is Generic
0 commit comments