File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
pandas-stubs/core/indexes Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -446,7 +446,7 @@ class DtDescriptor:
446446 @overload
447447 def __get__ (
448448 self , instance : Series [Never ], owner : type [Series ]
449- ) -> TimestampProperties | TimedeltaProperties | PeriodProperties : ...
449+ ) -> CombinedDatetimelikeProperties : ...
450450 @overload
451451 def __get__ (
452452 self , instance : Series [Timestamp ], owner : type [Series ]
Original file line number Diff line number Diff line change 88from pandas .core .arrays .timedeltas import TimedeltaArray
99from pandas .core .frame import DataFrame
1010from pandas .core .indexes .accessors import (
11+ CombinedDatetimelikeProperties ,
1112 DatetimeProperties ,
1213 PeriodProperties ,
1314 TimedeltaProperties ,
@@ -52,17 +53,30 @@ def test_property_dt() -> None:
5253 # python/mypy#19952: mypy gives Any
5354 check (
5455 assert_type ( # type: ignore[assert-type]
55- df ["ts" ].dt , "TimestampProperties | TimedeltaProperties | PeriodProperties"
56+ df ["ts" ].dt , CombinedDatetimelikeProperties
5657 ),
5758 DatetimeProperties ,
5859 )
5960 check (
6061 assert_type ( # type: ignore[assert-type]
61- df ["td" ].dt , "TimestampProperties | TimedeltaProperties | PeriodProperties"
62+ df ["td" ].dt , CombinedDatetimelikeProperties
6263 ),
6364 TimedeltaProperties ,
6465 )
6566
67+ check (
68+ assert_type (df ["ts" ].dt .year , "Series[int]" ), # type: ignore[assert-type]
69+ Series ,
70+ np .integer ,
71+ )
72+ check (
73+ assert_type ( # type: ignore[assert-type]
74+ df ["td" ].dt .total_seconds (), "Series[float]"
75+ ),
76+ Series ,
77+ np .floating ,
78+ )
79+
6680 if TYPE_CHECKING_INVALID_USAGE :
6781 _0 = Series ([1 ]).dt # type: ignore[arg-type] # pyright: ignore[reportAttributeAccessIssue]
6882 _1 = Series (["2025-01-01" ]).dt # type: ignore[arg-type] # pyright: ignore[reportAttributeAccessIssue]
You can’t perform that action at this time.
0 commit comments