1- import datetime as dt
21from datetime import (
2+ date ,
3+ time ,
34 timedelta ,
45 tzinfo as _tzinfo ,
56)
67from typing import (
7- Any ,
88 Generic ,
99 Literal ,
1010 TypeVar ,
1111 overload ,
12+ type_check_only ,
1213)
1314
1415import numpy as np
15- from pandas import (
16- DatetimeIndex ,
17- Index ,
18- PeriodIndex ,
19- Timedelta ,
20- TimedeltaIndex ,
21- Timestamp ,
22- )
2316from pandas .core .accessor import PandasDelegate
24- from pandas .core .arrays import (
25- DatetimeArray ,
26- PeriodArray ,
17+ from pandas .core .arrays .base import ExtensionArray
18+ from pandas .core .arrays .categorical import Categorical
19+ from pandas .core .arrays .datetimes import DatetimeArray
20+ from pandas .core .arrays .interval import IntervalArray
21+ from pandas .core .arrays .period import PeriodArray
22+ from pandas .core .arrays .timedeltas import TimedeltaArray
23+ from pandas .core .base import (
24+ IndexOpsMixin ,
25+ NoNewAttributesMixin ,
2726)
28- from pandas .core .base import NoNewAttributesMixin
2927from pandas .core .frame import DataFrame
30- from pandas .core .series import (
31- Series ,
32- )
28+ from pandas .core .indexes .base import Index
29+ from pandas .core .indexes .datetimes import DatetimeIndex
30+ from pandas .core .indexes .period import PeriodIndex
31+ from pandas .core .indexes .timedeltas import TimedeltaIndex
32+ from pandas .core .series import Series
3333from typing_extensions import Never
3434
35+ from pandas ._libs .interval import Interval
3536from pandas ._libs .tslibs import BaseOffset
3637from pandas ._libs .tslibs .offsets import DateOffset
3738from pandas ._libs .tslibs .period import Period
39+ from pandas ._libs .tslibs .timedeltas import Timedelta
40+ from pandas ._libs .tslibs .timestamps import Timestamp
3841from pandas ._typing import (
39- S1 ,
4042 TimeAmbiguous ,
4143 TimeNonexistent ,
4244 TimestampConvention ,
@@ -46,6 +48,8 @@ from pandas._typing import (
4648 np_ndarray_bool ,
4749)
4850
51+ from pandas .core .dtypes .dtypes import CategoricalDtype
52+
4953class Properties (PandasDelegate , NoNewAttributesMixin ): ...
5054
5155_DTFieldOpsReturnType = TypeVar ("_DTFieldOpsReturnType" , bound = Series [int ] | Index [int ])
@@ -129,10 +133,10 @@ class _DatetimeObjectOps(
129133): ...
130134
131135_DTOtherOpsDateReturnType = TypeVar (
132- "_DTOtherOpsDateReturnType" , bound = Series [dt . date ] | np_1darray [np .object_ ]
136+ "_DTOtherOpsDateReturnType" , bound = Series [date ] | np_1darray [np .object_ ]
133137)
134138_DTOtherOpsTimeReturnType = TypeVar (
135- "_DTOtherOpsTimeReturnType" , bound = Series [dt . time ] | np_1darray [np .object_ ]
139+ "_DTOtherOpsTimeReturnType" , bound = Series [time ] | np_1darray [np .object_ ]
136140)
137141
138142class _DatetimeOtherOps (Generic [_DTOtherOpsDateReturnType , _DTOtherOpsTimeReturnType ]):
@@ -380,8 +384,8 @@ class CombinedDatetimelikeProperties(
380384 Series [int ],
381385 Series [bool ],
382386 Series ,
383- Series [dt . date ],
384- Series [dt . time ],
387+ Series [date ],
388+ Series [time ],
385389 str ,
386390 Series [Timestamp ],
387391 Series [str ],
@@ -390,13 +394,15 @@ class CombinedDatetimelikeProperties(
390394 _TimedeltaPropertiesNoRounding [Series [int ], Series [float ]],
391395 _PeriodProperties ,
392396): ...
397+
398+ @type_check_only
393399class TimestampProperties (
394400 DatetimeProperties [
395401 Series [int ],
396402 Series [bool ],
397403 Series [Timestamp ],
398- Series [dt . date ],
399- Series [dt . time ],
404+ Series [date ],
405+ Series [time ],
400406 str ,
401407 Series [Timestamp ],
402408 Series [str ],
@@ -434,51 +440,47 @@ class TimedeltaIndexProperties(
434440 _DatetimeRoundingMethods [TimedeltaIndex ],
435441): ...
436442
437- class _dtDescriptor (CombinedDatetimelikeProperties , Generic [S1 ]):
438- @overload
439- def __get__ (self , instance : Series [Never ], owner : Any ) -> Never : ...
443+ @type_check_only
444+ class DtDescriptor :
440445 @overload
441- def __get__ (self , instance : Series [Period ], owner : Any ) -> PeriodProperties : ...
446+ def __get__ (self , instance : Series [Never ], owner : type [ Series ] ) -> Properties : ...
442447 @overload
443448 def __get__ (
444- self , instance : Series [Timestamp ], owner : Any
449+ self , instance : Series [Timestamp ], owner : type [ Series ]
445450 ) -> TimestampProperties : ...
446451 @overload
447452 def __get__ (
448- self , instance : Series [Timedelta ], owner : Any
453+ self , instance : Series [Timedelta ], owner : type [ Series ]
449454 ) -> TimedeltaProperties : ...
450455 @overload
451456 def __get__ (
452- self , instance : Series [S1 ], owner : Any
453- ) -> CombinedDatetimelikeProperties : ...
454- def round (
455- self ,
456- freq : str | BaseOffset | None ,
457- ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
458- nonexistent : (
459- Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
460- | timedelta
461- | Timedelta
462- ) = ...,
463- ) -> Series [S1 ]: ...
464- def floor (
465- self ,
466- freq : str | BaseOffset | None ,
467- ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
468- nonexistent : (
469- Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
470- | timedelta
471- | Timedelta
472- ) = ...,
473- ) -> Series [S1 ]: ...
474- def ceil (
475- self ,
476- freq : str | BaseOffset | None ,
477- ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
478- nonexistent : (
479- Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
480- | timedelta
481- | Timedelta
482- ) = ...,
483- ) -> Series [S1 ]: ...
484- def as_unit (self , unit : TimeUnit ) -> Series [S1 ]: ...
457+ self , instance : Series [Period ], owner : type [Series ]
458+ ) -> PeriodProperties : ...
459+
460+ @type_check_only
461+ class ArrayDescriptor :
462+ @overload
463+ def __get__ (
464+ self , instance : IndexOpsMixin [Never ], owner : type [IndexOpsMixin ]
465+ ) -> ExtensionArray : ...
466+ @overload
467+ def __get__ (
468+ self , instance : IndexOpsMixin [CategoricalDtype ], owner : type [IndexOpsMixin ]
469+ ) -> Categorical : ...
470+ @overload
471+ def __get__ (
472+ self , instance : IndexOpsMixin [Interval ], owner : type [IndexOpsMixin ]
473+ ) -> IntervalArray : ...
474+ @overload
475+ def __get__ (
476+ self , instance : IndexOpsMixin [Timestamp ], owner : type [IndexOpsMixin ]
477+ ) -> DatetimeArray : ...
478+ @overload
479+ def __get__ (
480+ self , instance : IndexOpsMixin [Timedelta ], owner : type [IndexOpsMixin ]
481+ ) -> TimedeltaArray : ...
482+ # should be NumpyExtensionArray
483+ @overload
484+ def __get__ (
485+ self , instance : IndexOpsMixin , owner : type [IndexOpsMixin ]
486+ ) -> ExtensionArray : ...
0 commit comments