@@ -8,7 +8,6 @@ from datetime import (
88from time import struct_time
99from typing import (
1010 ClassVar ,
11- Type ,
1211 TypeVar ,
1312 overload ,
1413)
@@ -22,9 +21,9 @@ from pandas._libs.tslibs import (
2221 Timedelta ,
2322)
2423
25- _S = TypeVar ("_S" )
24+ _S = TypeVar ("_S" , bound = datetime )
2625
27- def integer_op_not_supported (obj ) -> TypeError : ...
26+ def integer_op_not_supported (obj : object ) -> TypeError : ...
2827
2928class Timestamp (datetime ):
3029 min : ClassVar [Timestamp ]
@@ -35,17 +34,17 @@ class Timestamp(datetime):
3534
3635 # error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
3736 def __new__ ( # type: ignore[misc]
38- cls : Type [_S ],
37+ cls : type [_S ],
3938 ts_input : int
4039 | np .integer
4140 | float
4241 | str
4342 | _date
4443 | datetime
4544 | np .datetime64 = ...,
46- freq = ...,
45+ freq : int | None | str | BaseOffset = ...,
4746 tz : str | _tzinfo | None | int = ...,
48- unit = ...,
47+ unit : str | int | None = ...,
4948 year : int | None = ...,
5049 month : int | None = ...,
5150 day : int | None = ...,
@@ -80,24 +79,28 @@ class Timestamp(datetime):
8079 @property
8180 def fold (self ) -> int : ...
8281 @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 : ...
8483 @classmethod
85- def utcfromtimestamp (cls : Type [_S ], t : float ) -> _S : ...
84+ def utcfromtimestamp (cls : type [_S ], t : float ) -> _S : ...
8685 @classmethod
87- def today (cls : Type [_S ]) -> _S : ...
86+ def today (cls : type [_S ], tz : _tzinfo | str | None = ... ) -> _S : ...
8887 @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 : ...
9094 @classmethod
91- def now (cls : Type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
95+ def now (cls : type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
9296 @classmethod
93- def utcnow (cls : Type [_S ]) -> _S : ...
97+ def utcnow (cls : type [_S ]) -> _S : ...
98+ # error: Signature of "combine" incompatible with supertype "datetime"
9499 @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]
98101 @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 : ...
101104 def __format__ (self , fmt : str ) -> str : ...
102105 def toordinal (self ) -> int : ...
103106 def timetuple (self ) -> struct_time : ...
@@ -116,12 +119,12 @@ class Timestamp(datetime):
116119 second : int = ...,
117120 microsecond : int = ...,
118121 tzinfo : _tzinfo | None = ...,
119- * ,
120122 fold : int = ...,
121123 ) -> datetime : ...
122124 def astimezone (self : _S , tz : _tzinfo | None = ...) -> _S : ...
123125 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]
125128 @classmethod
126129 def strptime (cls , date_string : str , format : str ) -> datetime : ...
127130 def utcoffset (self ) -> timedelta | None : ...
@@ -131,12 +134,18 @@ class Timestamp(datetime):
131134 def __lt__ (self , other : datetime ) -> bool : ... # type: ignore
132135 def __ge__ (self , other : datetime ) -> bool : ... # type: ignore
133136 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 : ...
135143 def __radd__ (self : _S , other : timedelta ) -> _S : ...
136144 @overload # type: ignore
137145 def __sub__ (self , other : datetime ) -> timedelta : ...
138146 @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 : ...
140149 def __hash__ (self ) -> int : ...
141150 def weekday (self ) -> int : ...
142151 def isoweekday (self ) -> int : ...
@@ -157,23 +166,38 @@ class Timestamp(datetime):
157166 def is_year_end (self ) -> bool : ...
158167 def to_pydatetime (self , warn : bool = ...) -> datetime : ...
159168 def to_datetime64 (self ) -> np .datetime64 : ...
160- def to_period (self , freq ) -> Period : ...
169+ def to_period (self , freq : BaseOffset | str | None = ... ) -> Period : ...
161170 def to_julian_date (self ) -> np .float64 : ...
162171 @property
163172 def asm8 (self ) -> np .datetime64 : ...
164- def tz_convert (self : _S , tz ) -> _S : ...
173+ def tz_convert (self : _S , tz : _tzinfo | str | None ) -> _S : ...
165174 # TODO: could return NaT?
166175 def tz_localize (
167- self : _S , tz , ambiguous : str = ..., nonexistent : str = ...
176+ self : _S , tz : _tzinfo | str | None , ambiguous : str = ..., nonexistent : str = ...
168177 ) -> _S : ...
169178 def normalize (self : _S ) -> _S : ...
170179 # TODO: round/floor/ceil could return NaT?
171180 def round (
172- self : _S , freq , ambiguous : bool | str = ..., nonexistent : str = ...
181+ self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
173182 ) -> _S : ...
174183 def floor (
175- self : _S , freq , ambiguous : bool | str = ..., nonexistent : str = ...
184+ self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
176185 ) -> _S : ...
177186 def ceil (
178- self : _S , freq , ambiguous : bool | str = ..., nonexistent : str = ...
187+ self : _S , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
179188 ) -> _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