@@ -21,6 +21,7 @@ from pandas._libs.tslibs import (
2121 Tick ,
2222 Timedelta ,
2323)
24+ from pandas ._typing import Self
2425
2526_DatetimeT = TypeVar ("_DatetimeT" , bound = datetime )
2627
@@ -80,30 +81,28 @@ class Timestamp(datetime):
8081 @property
8182 def fold (self ) -> int : ...
8283 @classmethod
83- def fromtimestamp (
84- cls : type [_DatetimeT ], ts : float , tz : _tzinfo | None = ...
85- ) -> _DatetimeT : ...
84+ def fromtimestamp (cls , ts : float , tz : _tzinfo | None = ...) -> Self : ...
8685 @classmethod
87- def utcfromtimestamp (cls : type [ _DatetimeT ] , ts : float ) -> _DatetimeT : ...
86+ def utcfromtimestamp (cls , ts : float ) -> Self : ...
8887 @classmethod
89- def today (cls : type [ _DatetimeT ] , tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
88+ def today (cls , tz : _tzinfo | str | None = ...) -> Self : ...
9089 @classmethod
9190 def fromordinal (
92- cls : type [ _DatetimeT ] ,
91+ cls ,
9392 ordinal : int ,
9493 tz : _tzinfo | str | None = ...,
95- ) -> _DatetimeT : ...
94+ ) -> Self : ...
9695 @classmethod
97- def now (cls : type [ _DatetimeT ] , tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
96+ def now (cls , tz : _tzinfo | str | None = ...) -> Self : ...
9897 @classmethod
99- def utcnow (cls : type [ _DatetimeT ] ) -> _DatetimeT : ...
98+ def utcnow (cls ) -> Self : ...
10099 # error: Signature of "combine" incompatible with supertype "datetime"
101100 @classmethod
102101 def combine ( # type: ignore[override]
103102 cls , date : _date , time : _time
104103 ) -> datetime : ...
105104 @classmethod
106- def fromisoformat (cls : type [ _DatetimeT ] , date_string : str ) -> _DatetimeT : ...
105+ def fromisoformat (cls , date_string : str ) -> Self : ...
107106 def strftime (self , format : str ) -> str : ...
108107 def __format__ (self , fmt : str ) -> str : ...
109108 def toordinal (self ) -> int : ...
@@ -116,7 +115,7 @@ class Timestamp(datetime):
116115 # LSP violation: nanosecond is not present in datetime.datetime.replace
117116 # and has positional args following it
118117 def replace ( # type: ignore[override]
119- self : _DatetimeT ,
118+ self ,
120119 year : int | None = ...,
121120 month : int | None = ...,
122121 day : int | None = ...,
@@ -127,11 +126,9 @@ class Timestamp(datetime):
127126 nanosecond : int | None = ...,
128127 tzinfo : _tzinfo | type [object ] | None = ...,
129128 fold : int | None = ...,
130- ) -> _DatetimeT : ...
129+ ) -> Self : ...
131130 # LSP violation: datetime.datetime.astimezone has a default value for tz
132- def astimezone ( # type: ignore[override]
133- self : _DatetimeT , tz : _tzinfo | None
134- ) -> _DatetimeT : ...
131+ def astimezone (self , tz : _tzinfo | None ) -> Self : ... # type: ignore[override]
135132 def ctime (self ) -> str : ...
136133 def isoformat (self , sep : str = ..., timespec : str = ...) -> str : ...
137134 @classmethod
@@ -147,16 +144,12 @@ class Timestamp(datetime):
147144 @overload # type: ignore[override]
148145 def __add__ (self , other : np .ndarray ) -> np .ndarray : ...
149146 @overload
150- def __add__ (
151- self : _DatetimeT , other : timedelta | np .timedelta64 | Tick
152- ) -> _DatetimeT : ...
153- def __radd__ (self : _DatetimeT , other : timedelta ) -> _DatetimeT : ...
147+ def __add__ (self , other : timedelta | np .timedelta64 | Tick ) -> Self : ...
148+ def __radd__ (self , other : timedelta ) -> Self : ...
154149 @overload # type: ignore[override]
155150 def __sub__ (self , other : datetime ) -> Timedelta : ...
156151 @overload
157- def __sub__ (
158- self : _DatetimeT , other : timedelta | np .timedelta64 | Tick
159- ) -> _DatetimeT : ...
152+ def __sub__ (self , other : timedelta | np .timedelta64 | Tick ) -> Self : ...
160153 def __hash__ (self ) -> int : ...
161154 def weekday (self ) -> int : ...
162155 def isoweekday (self ) -> int : ...
@@ -181,25 +174,25 @@ class Timestamp(datetime):
181174 def to_julian_date (self ) -> np .float64 : ...
182175 @property
183176 def asm8 (self ) -> np .datetime64 : ...
184- def tz_convert (self : _DatetimeT , tz : _tzinfo | str | None ) -> _DatetimeT : ...
177+ def tz_convert (self , tz : _tzinfo | str | None ) -> Self : ...
185178 # TODO: could return NaT?
186179 def tz_localize (
187- self : _DatetimeT ,
180+ self ,
188181 tz : _tzinfo | str | None ,
189182 ambiguous : str = ...,
190183 nonexistent : str = ...,
191- ) -> _DatetimeT : ...
192- def normalize (self : _DatetimeT ) -> _DatetimeT : ...
184+ ) -> Self : ...
185+ def normalize (self ) -> Self : ...
193186 # TODO: round/floor/ceil could return NaT?
194187 def round (
195- self : _DatetimeT , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
196- ) -> _DatetimeT : ...
188+ self , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
189+ ) -> Self : ...
197190 def floor (
198- self : _DatetimeT , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
199- ) -> _DatetimeT : ...
191+ self , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
192+ ) -> Self : ...
200193 def ceil (
201- self : _DatetimeT , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
202- ) -> _DatetimeT : ...
194+ self , freq : str , ambiguous : bool | str = ..., nonexistent : str = ...
195+ ) -> Self : ...
203196 def day_name (self , locale : str | None = ...) -> str : ...
204197 def month_name (self , locale : str | None = ...) -> str : ...
205198 @property
0 commit comments