Skip to content

Commit 4c5a9d1

Browse files
committed
Added type hints to time
1 parent 4758081 commit 4c5a9d1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

shared-bindings/time/__init__.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//| written in MicroPython will work in CPython but not necessarily the other
4343
//| way around."""
4444
//|
45-
//| def monotonic() -> Any:
45+
//| def monotonic() -> float:
4646
//| """Returns an always increasing value of time with an unknown reference
4747
//| point. Only use it to compare against other values from `monotonic`.
4848
//|
@@ -57,7 +57,7 @@ STATIC mp_obj_t time_monotonic(void) {
5757
}
5858
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic);
5959

60-
//| def sleep(seconds: float) -> Any:
60+
//| def sleep(seconds: float) -> None:
6161
//| """Sleep for a given number of seconds.
6262
//|
6363
//| :param float seconds: the time to sleep in fractional seconds"""
@@ -93,7 +93,7 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp
9393
}
9494

9595
//| class struct_time:
96-
//| def __init__(self, time_tuple: Any) -> None:
96+
//| def __init__(self, time_tuple: tuple) -> None:
9797
//| """Structure used to capture a date and time. Note that it takes a tuple!
9898
//|
9999
//| :param tuple time_tuple: Tuple of time info: ``(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)``
@@ -198,7 +198,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) {
198198
mp_raise_RuntimeError(translate("RTC is not supported on this board"));
199199
}
200200

201-
//| def time() -> Any:
201+
//| def time() -> int:
202202
//| """Return the current time in seconds since since Jan 1, 1970.
203203
//|
204204
//| :return: the current time
@@ -214,7 +214,7 @@ STATIC mp_obj_t time_time(void) {
214214
}
215215
MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
216216

217-
//| def monotonic_ns() -> Any:
217+
//| def monotonic_ns() -> int:
218218
//| """Return the time of the specified clock clk_id in nanoseconds.
219219
//|
220220
//| :return: the current time
@@ -227,7 +227,7 @@ STATIC mp_obj_t time_monotonic_ns(void) {
227227
}
228228
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns);
229229

230-
//| def localtime(secs: Any) -> Any:
230+
//| def localtime(secs: int) -> struct_time:
231231
//| """Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in
232232
//| local time. If secs is not provided or None, the current time as returned
233233
//| by time() is used.
@@ -260,7 +260,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
260260
}
261261
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime);
262262

263-
//| def mktime(t: Any) -> Any:
263+
//| def mktime(t: struct_time) -> int:
264264
//| """This is the inverse function of localtime(). Its argument is the
265265
//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the
266266
//| dst flag if it is unknown) which expresses the time in local time, not UTC.

0 commit comments

Comments
 (0)