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 .offsets import DateOffset
37
38
from pandas ._libs .tslibs .period import Period
39
+ from pandas ._libs .tslibs .timedeltas import Timedelta
40
+ from pandas ._libs .tslibs .timestamps import Timestamp
38
41
from pandas ._typing import (
39
- S1 ,
40
42
TimeAmbiguous ,
41
43
TimeNonexistent ,
42
44
TimestampConvention ,
@@ -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 ]):
@@ -380,8 +384,8 @@ class CombinedDatetimelikeProperties(
380
384
Series [int ],
381
385
Series [bool ],
382
386
Series ,
383
- Series [dt . date ],
384
- Series [dt . time ],
387
+ Series [date ],
388
+ Series [time ],
385
389
str ,
386
390
Series [Timestamp ],
387
391
Series [str ],
@@ -390,13 +394,15 @@ class CombinedDatetimelikeProperties(
390
394
_TimedeltaPropertiesNoRounding [Series [int ], Series [float ]],
391
395
_PeriodProperties ,
392
396
): ...
397
+
398
+ @type_check_only
393
399
class TimestampProperties (
394
400
DatetimeProperties [
395
401
Series [int ],
396
402
Series [bool ],
397
403
Series [Timestamp ],
398
- Series [dt . date ],
399
- Series [dt . time ],
404
+ Series [date ],
405
+ Series [time ],
400
406
str ,
401
407
Series [Timestamp ],
402
408
Series [str ],
@@ -434,51 +440,47 @@ class TimedeltaIndexProperties(
434
440
_DatetimeRoundingMethods [TimedeltaIndex ],
435
441
): ...
436
442
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 :
440
445
@overload
441
- def __get__ (self , instance : Series [Period ], owner : Any ) -> PeriodProperties : ...
446
+ def __get__ (self , instance : Series [Never ], owner : type [ Series ] ) -> Properties : ...
442
447
@overload
443
448
def __get__ (
444
- self , instance : Series [Timestamp ], owner : Any
449
+ self , instance : Series [Timestamp ], owner : type [ Series ]
445
450
) -> TimestampProperties : ...
446
451
@overload
447
452
def __get__ (
448
- self , instance : Series [Timedelta ], owner : Any
453
+ self , instance : Series [Timedelta ], owner : type [ Series ]
449
454
) -> TimedeltaProperties : ...
450
455
@overload
451
456
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