@@ -36,6 +36,8 @@ This also allows type checking for operations on series that contain date/time d
3636the following example that creates two series of datetimes with corresponding arithmetic.
3737
3838``` python
39+ import pandas as pd
40+
3941s1 = pd.Series(pd.to_datetime([" 2022-05-01" , " 2022-06-01" ]))
4042reveal_type(s1)
4143s2 = pd.Series(pd.to_datetime([" 2022-05-15" , " 2022-06-15" ]))
@@ -46,19 +48,21 @@ ssum = s1 + s2
4648reveal_type(ssum)
4749```
4850
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
5053inappropriate to add two series containing ` Timestamp ` values. The types will be
5154revealed as follows:
5255
5356``` 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] "
5659ttest.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"
5862```
5963
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
6266the result of ` pd.to_timedelta() ` .
6367
6468### Interval is Generic
0 commit comments