@@ -21,7 +21,7 @@ from pandas._libs.tslibs import (
2121 Timedelta ,
2222)
2323
24- _S = TypeVar ("_S " , bound = datetime )
24+ _DatetimeT = TypeVar ("_DatetimeT " , bound = datetime )
2525
2626def integer_op_not_supported (obj : object ) -> TypeError : ...
2727
@@ -34,7 +34,7 @@ class Timestamp(datetime):
3434
3535 # error: "__new__" must return a class instance (got "Union[Timestamp, NaTType]")
3636 def __new__ ( # type: ignore[misc]
37- cls : type [_S ],
37+ cls : type [_DatetimeT ],
3838 ts_input : int
3939 | np .integer
4040 | float
@@ -56,7 +56,7 @@ class Timestamp(datetime):
5656 tzinfo : _tzinfo | None = ...,
5757 * ,
5858 fold : int | None = ...,
59- ) -> _S | NaTType : ...
59+ ) -> _DatetimeT | NaTType : ...
6060 def _set_freq (self , freq : BaseOffset | None ) -> None : ...
6161 @property
6262 def year (self ) -> int : ...
@@ -79,27 +79,29 @@ class Timestamp(datetime):
7979 @property
8080 def fold (self ) -> int : ...
8181 @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 : ...
8385 @classmethod
84- def utcfromtimestamp (cls : type [_S ], t : float ) -> _S : ...
86+ def utcfromtimestamp (cls : type [_DatetimeT ], t : float ) -> _DatetimeT : ...
8587 @classmethod
86- def today (cls : type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
88+ def today (cls : type [_DatetimeT ], tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
8789 @classmethod
8890 def fromordinal (
89- cls : type [_S ],
91+ cls : type [_DatetimeT ],
9092 ordinal : int ,
9193 freq : str | BaseOffset | None = ...,
9294 tz : _tzinfo | str | None = ...,
93- ) -> _S : ...
95+ ) -> _DatetimeT : ...
9496 @classmethod
95- def now (cls : type [_S ], tz : _tzinfo | str | None = ...) -> _S : ...
97+ def now (cls : type [_DatetimeT ], tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
9698 @classmethod
97- def utcnow (cls : type [_S ]) -> _S : ...
99+ def utcnow (cls : type [_DatetimeT ]) -> _DatetimeT : ...
98100 # error: Signature of "combine" incompatible with supertype "datetime"
99101 @classmethod
100102 def combine (cls , date : _date , time : _time ) -> datetime : ... # type: ignore[override]
101103 @classmethod
102- def fromisoformat (cls : type [_S ], date_string : str ) -> _S : ...
104+ def fromisoformat (cls : type [_DatetimeT ], date_string : str ) -> _DatetimeT : ...
103105 def strftime (self , format : str ) -> str : ...
104106 def __format__ (self , fmt : str ) -> str : ...
105107 def toordinal (self ) -> int : ...
@@ -121,10 +123,9 @@ class Timestamp(datetime):
121123 tzinfo : _tzinfo | None = ...,
122124 fold : int = ...,
123125 ) -> datetime : ...
124- def astimezone (self : _S , tz : _tzinfo | None = ...) -> _S : ...
126+ def astimezone (self : _DatetimeT , tz : _tzinfo | None = ...) -> _DatetimeT : ...
125127 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 : ...
128129 @classmethod
129130 def strptime (cls , date_string : str , format : str ) -> datetime : ...
130131 def utcoffset (self ) -> timedelta | None : ...
@@ -139,8 +140,8 @@ class Timestamp(datetime):
139140 def __add__ (self , other : np .ndarray ) -> np .ndarray : ...
140141 @overload
141142 # 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 : ...
144145 @overload # type: ignore
145146 def __sub__ (self , other : datetime ) -> timedelta : ...
146147 @overload
@@ -170,22 +171,25 @@ class Timestamp(datetime):
170171 def to_julian_date (self ) -> np .float64 : ...
171172 @property
172173 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 : ...
174175 # TODO: could return NaT?
175176 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 : ...
179183 # TODO: round/floor/ceil could return NaT?
180184 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 : ...
183187 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 : ...
186190 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 : ...
189193 def day_name (self , locale : str | None = ...) -> str : ...
190194 def month_name (self , locale : str | None = ...) -> str : ...
191195 @property
0 commit comments