@@ -21,6 +21,7 @@ from pandas._libs.tslibs import (
21
21
Tick ,
22
22
Timedelta ,
23
23
)
24
+ from pandas ._typing import Self
24
25
25
26
_DatetimeT = TypeVar ("_DatetimeT" , bound = datetime )
26
27
@@ -80,30 +81,28 @@ class Timestamp(datetime):
80
81
@property
81
82
def fold (self ) -> int : ...
82
83
@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 : ...
86
85
@classmethod
87
- def utcfromtimestamp (cls : type [ _DatetimeT ] , ts : float ) -> _DatetimeT : ...
86
+ def utcfromtimestamp (cls , ts : float ) -> Self : ...
88
87
@classmethod
89
- def today (cls : type [ _DatetimeT ] , tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
88
+ def today (cls , tz : _tzinfo | str | None = ...) -> Self : ...
90
89
@classmethod
91
90
def fromordinal (
92
- cls : type [ _DatetimeT ] ,
91
+ cls ,
93
92
ordinal : int ,
94
93
tz : _tzinfo | str | None = ...,
95
- ) -> _DatetimeT : ...
94
+ ) -> Self : ...
96
95
@classmethod
97
- def now (cls : type [ _DatetimeT ] , tz : _tzinfo | str | None = ...) -> _DatetimeT : ...
96
+ def now (cls , tz : _tzinfo | str | None = ...) -> Self : ...
98
97
@classmethod
99
- def utcnow (cls : type [ _DatetimeT ] ) -> _DatetimeT : ...
98
+ def utcnow (cls ) -> Self : ...
100
99
# error: Signature of "combine" incompatible with supertype "datetime"
101
100
@classmethod
102
101
def combine ( # type: ignore[override]
103
102
cls , date : _date , time : _time
104
103
) -> datetime : ...
105
104
@classmethod
106
- def fromisoformat (cls : type [ _DatetimeT ] , date_string : str ) -> _DatetimeT : ...
105
+ def fromisoformat (cls , date_string : str ) -> Self : ...
107
106
def strftime (self , format : str ) -> str : ...
108
107
def __format__ (self , fmt : str ) -> str : ...
109
108
def toordinal (self ) -> int : ...
@@ -116,7 +115,7 @@ class Timestamp(datetime):
116
115
# LSP violation: nanosecond is not present in datetime.datetime.replace
117
116
# and has positional args following it
118
117
def replace ( # type: ignore[override]
119
- self : _DatetimeT ,
118
+ self ,
120
119
year : int | None = ...,
121
120
month : int | None = ...,
122
121
day : int | None = ...,
@@ -127,11 +126,9 @@ class Timestamp(datetime):
127
126
nanosecond : int | None = ...,
128
127
tzinfo : _tzinfo | type [object ] | None = ...,
129
128
fold : int | None = ...,
130
- ) -> _DatetimeT : ...
129
+ ) -> Self : ...
131
130
# 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]
135
132
def ctime (self ) -> str : ...
136
133
def isoformat (self , sep : str = ..., timespec : str = ...) -> str : ...
137
134
@classmethod
@@ -147,16 +144,12 @@ class Timestamp(datetime):
147
144
@overload # type: ignore[override]
148
145
def __add__ (self , other : np .ndarray ) -> np .ndarray : ...
149
146
@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 : ...
154
149
@overload # type: ignore[override]
155
150
def __sub__ (self , other : datetime ) -> Timedelta : ...
156
151
@overload
157
- def __sub__ (
158
- self : _DatetimeT , other : timedelta | np .timedelta64 | Tick
159
- ) -> _DatetimeT : ...
152
+ def __sub__ (self , other : timedelta | np .timedelta64 | Tick ) -> Self : ...
160
153
def __hash__ (self ) -> int : ...
161
154
def weekday (self ) -> int : ...
162
155
def isoweekday (self ) -> int : ...
@@ -181,25 +174,25 @@ class Timestamp(datetime):
181
174
def to_julian_date (self ) -> np .float64 : ...
182
175
@property
183
176
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 : ...
185
178
# TODO: could return NaT?
186
179
def tz_localize (
187
- self : _DatetimeT ,
180
+ self ,
188
181
tz : _tzinfo | str | None ,
189
182
ambiguous : str = ...,
190
183
nonexistent : str = ...,
191
- ) -> _DatetimeT : ...
192
- def normalize (self : _DatetimeT ) -> _DatetimeT : ...
184
+ ) -> Self : ...
185
+ def normalize (self ) -> Self : ...
193
186
# TODO: round/floor/ceil could return NaT?
194
187
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 : ...
197
190
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 : ...
200
193
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 : ...
203
196
def day_name (self , locale : str | None = ...) -> str : ...
204
197
def month_name (self , locale : str | None = ...) -> str : ...
205
198
@property
0 commit comments