@@ -8,7 +8,6 @@ from datetime import (
8
8
from time import struct_time
9
9
from typing import (
10
10
ClassVar ,
11
- Type ,
12
11
TypeVar ,
13
12
overload ,
14
13
)
@@ -22,9 +21,9 @@ from pandas._libs.tslibs import (
22
21
Timedelta ,
23
22
)
24
23
25
- _S = TypeVar ("_S" )
24
+ _S = TypeVar ("_S" , bound = datetime )
26
25
27
- def integer_op_not_supported (obj ) -> TypeError : ...
26
+ def integer_op_not_supported (obj : object ) -> TypeError : ...
28
27
29
28
class Timestamp (datetime ):
30
29
min : ClassVar [Timestamp ]
@@ -35,17 +34,17 @@ class Timestamp(datetime):
35
34
36
35
# error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
37
36
def __new__ ( # type: ignore[misc]
38
- cls : Type [_S ],
37
+ cls : type [_S ],
39
38
ts_input : int
40
39
| np .integer
41
40
| float
42
41
| str
43
42
| _date
44
43
| datetime
45
44
| np .datetime64 = ...,
46
- freq = ...,
45
+ freq : int | None | str | BaseOffset = ...,
47
46
tz : str | _tzinfo | None | int = ...,
48
- unit = ...,
47
+ unit : str | int | None = ...,
49
48
year : int | None = ...,
50
49
month : int | None = ...,
51
50
day : int | None = ...,
@@ -80,24 +79,28 @@ class Timestamp(datetime):
80
79
@property
81
80
def fold (self ) -> int : ...
82
81
@classmethod
83
- def fromtimestamp (cls : Type [_S ], t : float , tz : _tzinfo | None = ...) -> _S : ...
82
+ def fromtimestamp (cls : type [_S ], t : float , tz : _tzinfo | None = ...) -> _S : ...
84
83
@classmethod
85
- def utcfromtimestamp (cls : Type [_S ], t : float ) -> _S : ...
84
+ def utcfromtimestamp (cls : type [_S ], t : float ) -> _S : ...
86
85
@classmethod
87
- def today (cls : Type [_S ]) -> _S : ...
86
+ def today (cls : type [_S ], tz : _tzinfo | str | None = ... ) -> _S : ...
88
87
@classmethod
89
- def fromordinal (cls : Type [_S ], n : int ) -> _S : ...
88
+ def fromordinal (
89
+ cls : type [_S ],
90
+ ordinal : int ,
91
+ freq : str | BaseOffset | None = ...,
92
+ tz : _tzinfo | str | None = ...,
93
+ ) -> _S : ...
90
94
@classmethod
91
- def now (cls : Type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
95
+ def now (cls : type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
92
96
@classmethod
93
- def utcnow (cls : Type [_S ]) -> _S : ...
97
+ def utcnow (cls : type [_S ]) -> _S : ...
98
+ # error: Signature of "combine" incompatible with supertype "datetime"
94
99
@classmethod
95
- def combine (
96
- cls , date : _date , time : _time , tzinfo : _tzinfo | None = ...
97
- ) -> datetime : ...
100
+ def combine (cls , date : _date , time : _time ) -> datetime : ... # type: ignore[override]
98
101
@classmethod
99
- def fromisoformat (cls : Type [_S ], date_string : str ) -> _S : ...
100
- def strftime (self , fmt : str ) -> str : ...
102
+ def fromisoformat (cls : type [_S ], date_string : str ) -> _S : ...
103
+ def strftime (self , format : str ) -> str : ...
101
104
def __format__ (self , fmt : str ) -> str : ...
102
105
def toordinal (self ) -> int : ...
103
106
def timetuple (self ) -> struct_time : ...
@@ -116,12 +119,12 @@ class Timestamp(datetime):
116
119
second : int = ...,
117
120
microsecond : int = ...,
118
121
tzinfo : _tzinfo | None = ...,
119
- * ,
120
122
fold : int = ...,
121
123
) -> datetime : ...
122
124
def astimezone (self : _S , tz : _tzinfo | None = ...) -> _S : ...
123
125
def ctime (self ) -> str : ...
124
- def isoformat (self , sep : str = ..., timespec : str = ...) -> str : ...
126
+ # error: Signature of "isoformat" incompatible with supertype "datetime"
127
+ def isoformat (self , sep : str = ...) -> str : ... # type: ignore[override]
125
128
@classmethod
126
129
def strptime (cls , date_string : str , format : str ) -> datetime : ...
127
130
def utcoffset (self ) -> timedelta | None : ...
@@ -131,12 +134,18 @@ class Timestamp(datetime):
131
134
def __lt__ (self , other : datetime ) -> bool : ... # type: ignore
132
135
def __ge__ (self , other : datetime ) -> bool : ... # type: ignore
133
136
def __gt__ (self , other : datetime ) -> bool : ... # type: ignore
134
- def __add__ (self : _S , other : timedelta ) -> _S : ...
137
+ # error: Signature of "__add__" incompatible with supertype "date"/"datetime"
138
+ @overload # type: ignore[override]
139
+ def __add__ (self , other : np .ndarray ) -> np .ndarray : ...
140
+ @overload
141
+ # TODO: other can also be Tick (but it cannot be resolved)
142
+ def __add__ (self : _S , other : timedelta | np .timedelta64 ) -> _S : ...
135
143
def __radd__ (self : _S , other : timedelta ) -> _S : ...
136
144
@overload # type: ignore
137
145
def __sub__ (self , other : datetime ) -> timedelta : ...
138
146
@overload
139
- def __sub__ (self , other : timedelta ) -> datetime : ...
147
+ # TODO: other can also be Tick (but it cannot be resolved)
148
+ def __sub__ (self , other : timedelta | np .timedelta64 ) -> datetime : ...
140
149
def __hash__ (self ) -> int : ...
141
150
def weekday (self ) -> int : ...
142
151
def isoweekday (self ) -> int : ...
@@ -157,23 +166,38 @@ class Timestamp(datetime):
157
166
def is_year_end (self ) -> bool : ...
158
167
def to_pydatetime (self , warn : bool = ...) -> datetime : ...
159
168
def to_datetime64 (self ) -> np .datetime64 : ...
160
- def to_period (self , freq ) -> Period : ...
169
+ def to_period (self , freq : BaseOffset | str | None = ... ) -> Period : ...
161
170
def to_julian_date (self ) -> np .float64 : ...
162
171
@property
163
172
def asm8 (self ) -> np .datetime64 : ...
164
- def tz_convert (self : _S , tz ) -> _S : ...
173
+ def tz_convert (self : _S , tz : _tzinfo | str | None ) -> _S : ...
165
174
# TODO: could return NaT?
166
175
def tz_localize (
167
- self : _S , tz , ambiguous : str = ..., nonexistent : str = ...
176
+ self : _S , tz : _tzinfo | str | None , ambiguous : str = ..., nonexistent : str = ...
168
177
) -> _S : ...
169
178
def normalize (self : _S ) -> _S : ...
170
179
# TODO: round/floor/ceil could return NaT?
171
180
def round (
172
- self : _S , freq , ambiguous : bool | str = ..., nonexistent : str = ...
181
+ self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
173
182
) -> _S : ...
174
183
def floor (
175
- self : _S , freq , ambiguous : bool | str = ..., nonexistent : str = ...
184
+ self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
176
185
) -> _S : ...
177
186
def ceil (
178
- self : _S , freq , ambiguous : bool | str = ..., nonexistent : str = ...
187
+ self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
179
188
) -> _S : ...
189
+ def day_name (self , locale : str | None = ...) -> str : ...
190
+ def month_name (self , locale : str | None = ...) -> str : ...
191
+ @property
192
+ def day_of_week (self ) -> int : ...
193
+ @property
194
+ def day_of_month (self ) -> int : ...
195
+ @property
196
+ def day_of_year (self ) -> int : ...
197
+ @property
198
+ def quarter (self ) -> int : ...
199
+ @property
200
+ def week (self ) -> int : ...
201
+ def to_numpy (
202
+ self , dtype : np .dtype | None = ..., copy : bool = ...
203
+ ) -> np .datetime64 : ...
0 commit comments