1
- import datetime as dt
2
1
from datetime import (
2
+ date ,
3
+ time ,
3
4
timedelta ,
4
5
tzinfo as _tzinfo ,
5
6
)
6
7
from typing import (
7
- Any ,
8
8
Generic ,
9
9
Literal ,
10
10
TypeVar ,
11
11
overload ,
12
+ type_check_only ,
12
13
)
13
14
14
15
import numpy as np
15
- from pandas import (
16
- DatetimeIndex ,
17
- Index ,
18
- PeriodIndex ,
19
- Timedelta ,
20
- TimedeltaIndex ,
21
- Timestamp ,
22
- )
23
16
from 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 ,
27
26
)
28
- from pandas .core .base import NoNewAttributesMixin
29
27
from 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
33
33
from typing_extensions import Never
34
34
35
+ from pandas ._libs .interval import Interval
35
36
from pandas ._libs .tslibs import BaseOffset
36
37
from pandas ._libs .tslibs .period import Period
38
+ from pandas ._libs .tslibs .timedeltas import Timedelta
39
+ from pandas ._libs .tslibs .timestamps import Timestamp
37
40
from pandas ._typing import (
38
- S1 ,
39
41
Frequency ,
40
42
TimeAmbiguous ,
41
43
TimeNonexistent ,
@@ -46,6 +48,8 @@ from pandas._typing import (
46
48
np_ndarray_bool ,
47
49
)
48
50
51
+ from pandas .core .dtypes .dtypes import CategoricalDtype
52
+
49
53
class Properties (PandasDelegate , NoNewAttributesMixin ): ...
50
54
51
55
_DTFieldOpsReturnType = TypeVar ("_DTFieldOpsReturnType" , bound = Series [int ] | Index [int ])
@@ -129,10 +133,10 @@ class _DatetimeObjectOps(
129
133
): ...
130
134
131
135
_DTOtherOpsDateReturnType = TypeVar (
132
- "_DTOtherOpsDateReturnType" , bound = Series [dt . date ] | np_1darray [np .object_ ]
136
+ "_DTOtherOpsDateReturnType" , bound = Series [date ] | np_1darray [np .object_ ]
133
137
)
134
138
_DTOtherOpsTimeReturnType = TypeVar (
135
- "_DTOtherOpsTimeReturnType" , bound = Series [dt . time ] | np_1darray [np .object_ ]
139
+ "_DTOtherOpsTimeReturnType" , bound = Series [time ] | np_1darray [np .object_ ]
136
140
)
137
141
138
142
class _DatetimeOtherOps (Generic [_DTOtherOpsDateReturnType , _DTOtherOpsTimeReturnType ]):
@@ -378,8 +382,8 @@ class CombinedDatetimelikeProperties(
378
382
Series [int ],
379
383
Series [bool ],
380
384
Series ,
381
- Series [dt . date ],
382
- Series [dt . time ],
385
+ Series [date ],
386
+ Series [time ],
383
387
str ,
384
388
Series [Timestamp ],
385
389
Series [str ],
@@ -388,13 +392,15 @@ class CombinedDatetimelikeProperties(
388
392
_TimedeltaPropertiesNoRounding [Series [int ], Series [float ]],
389
393
_PeriodProperties ,
390
394
): ...
395
+
396
+ @type_check_only
391
397
class TimestampProperties (
392
398
DatetimeProperties [
393
399
Series [int ],
394
400
Series [bool ],
395
401
Series [Timestamp ],
396
- Series [dt . date ],
397
- Series [dt . time ],
402
+ Series [date ],
403
+ Series [time ],
398
404
str ,
399
405
Series [Timestamp ],
400
406
Series [str ],
@@ -432,51 +438,47 @@ class TimedeltaIndexProperties(
432
438
_DatetimeRoundingMethods [TimedeltaIndex ],
433
439
): ...
434
440
435
- class _dtDescriptor (CombinedDatetimelikeProperties , Generic [S1 ]):
436
- @overload
437
- def __get__ (self , instance : Series [Never ], owner : Any ) -> Never : ...
441
+ @type_check_only
442
+ class DtDescriptor :
438
443
@overload
439
- def __get__ (self , instance : Series [Period ], owner : Any ) -> PeriodProperties : ...
444
+ def __get__ (self , instance : Series [Never ], owner : type [ Series ] ) -> Properties : ...
440
445
@overload
441
446
def __get__ (
442
- self , instance : Series [Timestamp ], owner : Any
447
+ self , instance : Series [Timestamp ], owner : type [ Series ]
443
448
) -> TimestampProperties : ...
444
449
@overload
445
450
def __get__ (
446
- self , instance : Series [Timedelta ], owner : Any
451
+ self , instance : Series [Timedelta ], owner : type [ Series ]
447
452
) -> TimedeltaProperties : ...
448
453
@overload
449
454
def __get__ (
450
- self , instance : Series [S1 ], owner : Any
451
- ) -> CombinedDatetimelikeProperties : ...
452
- def round (
453
- self ,
454
- freq : Frequency | None ,
455
- ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
456
- nonexistent : (
457
- Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
458
- | timedelta
459
- | Timedelta
460
- ) = ...,
461
- ) -> Series [S1 ]: ...
462
- def floor (
463
- self ,
464
- freq : Frequency | None ,
465
- ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
466
- nonexistent : (
467
- Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
468
- | timedelta
469
- | Timedelta
470
- ) = ...,
471
- ) -> Series [S1 ]: ...
472
- def ceil (
473
- self ,
474
- freq : Frequency | None ,
475
- ambiguous : Literal ["raise" , "infer" , "NaT" ] | bool | np_ndarray_bool = ...,
476
- nonexistent : (
477
- Literal ["shift_forward" , "shift_backward" , "NaT" , "raise" ]
478
- | timedelta
479
- | Timedelta
480
- ) = ...,
481
- ) -> Series [S1 ]: ...
482
- def as_unit (self , unit : TimeUnit ) -> Series [S1 ]: ...
455
+ self , instance : Series [Period ], owner : type [Series ]
456
+ ) -> PeriodProperties : ...
457
+
458
+ @type_check_only
459
+ class ArrayDescriptor :
460
+ @overload
461
+ def __get__ (
462
+ self , instance : IndexOpsMixin [Never ], owner : type [IndexOpsMixin ]
463
+ ) -> ExtensionArray : ...
464
+ @overload
465
+ def __get__ (
466
+ self , instance : IndexOpsMixin [CategoricalDtype ], owner : type [IndexOpsMixin ]
467
+ ) -> Categorical : ...
468
+ @overload
469
+ def __get__ (
470
+ self , instance : IndexOpsMixin [Interval ], owner : type [IndexOpsMixin ]
471
+ ) -> IntervalArray : ...
472
+ @overload
473
+ def __get__ (
474
+ self , instance : IndexOpsMixin [Timestamp ], owner : type [IndexOpsMixin ]
475
+ ) -> DatetimeArray : ...
476
+ @overload
477
+ def __get__ (
478
+ self , instance : IndexOpsMixin [Timedelta ], owner : type [IndexOpsMixin ]
479
+ ) -> TimedeltaArray : ...
480
+ # should be NumpyExtensionArray
481
+ @overload
482
+ def __get__ (
483
+ self , instance : IndexOpsMixin , owner : type [IndexOpsMixin ]
484
+ ) -> ExtensionArray : ...
0 commit comments