@@ -70,7 +70,14 @@ class date:
70
70
@property
71
71
def day (self ) -> int : ...
72
72
def ctime (self ) -> str : ...
73
- def strftime (self , __format : str ) -> str : ...
73
+ # On <3.12, the name of the parameter in the pure-Python implementation
74
+ # didn't match the name in the C implementation,
75
+ # meaning it is only *safe* to pass it as a keyword argument on 3.12+
76
+ if sys .version_info >= (3 , 12 ):
77
+ def strftime (self , format : str ) -> str : ...
78
+ else :
79
+ def strftime (self , __format : str ) -> str : ...
80
+
74
81
def __format__ (self , __fmt : str ) -> str : ...
75
82
def isoformat (self ) -> str : ...
76
83
def timetuple (self ) -> struct_time : ...
@@ -140,7 +147,14 @@ class time:
140
147
def isoformat (self , timespec : str = ...) -> str : ...
141
148
@classmethod
142
149
def fromisoformat (cls : type [Self ], __time_string : str ) -> Self : ...
143
- def strftime (self , __format : str ) -> str : ...
150
+ # On <3.12, the name of the parameter in the pure-Python implementation
151
+ # didn't match the name in the C implementation,
152
+ # meaning it is only *safe* to pass it as a keyword argument on 3.12+
153
+ if sys .version_info >= (3 , 12 ):
154
+ def strftime (self , format : str ) -> str : ...
155
+ else :
156
+ def strftime (self , __format : str ) -> str : ...
157
+
144
158
def __format__ (self , __fmt : str ) -> str : ...
145
159
def utcoffset (self ) -> timedelta | None : ...
146
160
def tzname (self ) -> str | None : ...
@@ -233,11 +247,16 @@ class datetime(date):
233
247
def tzinfo (self ) -> _TzInfo | None : ...
234
248
@property
235
249
def fold (self ) -> int : ...
236
- # The first parameter in `fromtimestamp` is actually positional-or-keyword,
237
- # but it is named "timestamp" in the C implementation and "t" in the Python implementation,
238
- # so it is only truly *safe* to pass it as a positional argument.
239
- @classmethod
240
- def fromtimestamp (cls : type [Self ], __timestamp : float , tz : _TzInfo | None = ...) -> Self : ...
250
+ # On <3.12, the name of the first parameter in the pure-Python implementation
251
+ # didn't match the name in the C implementation,
252
+ # meaning it is only *safe* to pass it as a keyword argument on 3.12+
253
+ if sys .version_info >= (3 , 12 ):
254
+ @classmethod
255
+ def fromtimestamp (cls : type [Self ], timestamp : float , tz : _TzInfo | None = ...) -> Self : ...
256
+ else :
257
+ @classmethod
258
+ def fromtimestamp (cls : type [Self ], __timestamp : float , tz : _TzInfo | None = ...) -> Self : ...
259
+
241
260
@classmethod
242
261
def utcfromtimestamp (cls : type [Self ], __t : float ) -> Self : ...
243
262
if sys .version_info >= (3 , 8 ):
0 commit comments