@@ -21,7 +21,7 @@ from pandas._libs.tslibs import (
21
21
Timedelta ,
22
22
)
23
23
24
- _S = TypeVar ("_S " , bound = datetime )
24
+ _DatetimeT = TypeVar ("_DatetimeT " , bound = datetime )
25
25
26
26
def integer_op_not_supported (obj : object ) -> TypeError : ...
27
27
@@ -34,7 +34,7 @@ class Timestamp(datetime):
34
34
35
35
# error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
36
36
def __new__ ( # type: ignore[misc]
37
- cls : type [_S ],
37
+ cls : type [_DatetimeT ],
38
38
ts_input : int
39
39
| np .integer
40
40
| float
@@ -56,7 +56,7 @@ class Timestamp(datetime):
56
56
tzinfo : _tzinfo | None = ...,
57
57
* ,
58
58
fold : int | None = ...,
59
- ) -> _S | NaTType : ...
59
+ ) -> _DatetimeT | NaTType : ...
60
60
def _set_freq (self , freq : BaseOffset | None ) -> None : ...
61
61
@property
62
62
def year (self ) -> int : ...
@@ -79,27 +79,29 @@ class Timestamp(datetime):
79
79
@property
80
80
def fold (self ) -> int : ...
81
81
@classmethod
82
- def fromtimestamp (cls : type [_S ], t : float , tz : _tzinfo | None = ...) -> _S : ...
82
+ def fromtimestamp (
83
+ cls : type [_DatetimeT ], t : float , tz : _tzinfo | None = ...
84
+ ) -> _DatetimeT : ...
83
85
@classmethod
84
- def utcfromtimestamp (cls : type [_S ], t : float ) -> _S : ...
86
+ def utcfromtimestamp (cls : type [_DatetimeT ], t : float ) -> _DatetimeT : ...
85
87
@classmethod
86
- def today (cls : type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
88
+ def today (cls : type [_DatetimeT ], tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
87
89
@classmethod
88
90
def fromordinal (
89
- cls : type [_S ],
91
+ cls : type [_DatetimeT ],
90
92
ordinal : int ,
91
93
freq : str | BaseOffset | None = ...,
92
94
tz : _tzinfo | str | None = ...,
93
- ) -> _S : ...
95
+ ) -> _DatetimeT : ...
94
96
@classmethod
95
- def now (cls : type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
97
+ def now (cls : type [_DatetimeT ], tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
96
98
@classmethod
97
- def utcnow (cls : type [_S ]) -> _S : ...
99
+ def utcnow (cls : type [_DatetimeT ]) -> _DatetimeT : ...
98
100
# error: Signature of "combine" incompatible with supertype "datetime"
99
101
@classmethod
100
102
def combine (cls , date : _date , time : _time ) -> datetime : ... # type: ignore[override]
101
103
@classmethod
102
- def fromisoformat (cls : type [_S ], date_string : str ) -> _S : ...
104
+ def fromisoformat (cls : type [_DatetimeT ], date_string : str ) -> _DatetimeT : ...
103
105
def strftime (self , format : str ) -> str : ...
104
106
def __format__ (self , fmt : str ) -> str : ...
105
107
def toordinal (self ) -> int : ...
@@ -121,10 +123,9 @@ class Timestamp(datetime):
121
123
tzinfo : _tzinfo | None = ...,
122
124
fold : int = ...,
123
125
) -> datetime : ...
124
- def astimezone (self : _S , tz : _tzinfo | None = ...) -> _S : ...
126
+ def astimezone (self : _DatetimeT , tz : _tzinfo | None = ...) -> _DatetimeT : ...
125
127
def ctime (self ) -> str : ...
126
- # error: Signature of "isoformat" incompatible with supertype "datetime"
127
- def isoformat (self , sep : str = ...) -> str : ... # type: ignore[override]
128
+ def isoformat (self , sep : str = ..., timespec : str = ...) -> str : ...
128
129
@classmethod
129
130
def strptime (cls , date_string : str , format : str ) -> datetime : ...
130
131
def utcoffset (self ) -> timedelta | None : ...
@@ -139,8 +140,8 @@ class Timestamp(datetime):
139
140
def __add__ (self , other : np .ndarray ) -> np .ndarray : ...
140
141
@overload
141
142
# TODO: other can also be Tick (but it cannot be resolved)
142
- def __add__ (self : _S , other : timedelta | np .timedelta64 ) -> _S : ...
143
- def __radd__ (self : _S , other : timedelta ) -> _S : ...
143
+ def __add__ (self : _DatetimeT , other : timedelta | np .timedelta64 ) -> _DatetimeT : ...
144
+ def __radd__ (self : _DatetimeT , other : timedelta ) -> _DatetimeT : ...
144
145
@overload # type: ignore
145
146
def __sub__ (self , other : datetime ) -> timedelta : ...
146
147
@overload
@@ -170,22 +171,25 @@ class Timestamp(datetime):
170
171
def to_julian_date (self ) -> np .float64 : ...
171
172
@property
172
173
def asm8 (self ) -> np .datetime64 : ...
173
- def tz_convert (self : _S , tz : _tzinfo | str | None ) -> _S : ...
174
+ def tz_convert (self : _DatetimeT , tz : _tzinfo | str | None ) -> _DatetimeT : ...
174
175
# TODO: could return NaT?
175
176
def tz_localize (
176
- self : _S , tz : _tzinfo | str | None , ambiguous : str = ..., nonexistent : str = ...
177
- ) -> _S : ...
178
- def normalize (self : _S ) -> _S : ...
177
+ self : _DatetimeT ,
178
+ tz : _tzinfo | str | None ,
179
+ ambiguous : str = ...,
180
+ nonexistent : str = ...,
181
+ ) -> _DatetimeT : ...
182
+ def normalize (self : _DatetimeT ) -> _DatetimeT : ...
179
183
# TODO: round/floor/ceil could return NaT?
180
184
def round (
181
- self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
182
- ) -> _S : ...
185
+ self : _DatetimeT , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
186
+ ) -> _DatetimeT : ...
183
187
def floor (
184
- self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
185
- ) -> _S : ...
188
+ self : _DatetimeT , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
189
+ ) -> _DatetimeT : ...
186
190
def ceil (
187
- self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
188
- ) -> _S : ...
191
+ self : _DatetimeT , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
192
+ ) -> _DatetimeT : ...
189
193
def day_name (self , locale : str | None = ...) -> str : ...
190
194
def month_name (self , locale : str | None = ...) -> str : ...
191
195
@property
0 commit comments