From 9274e6a681937cdbead3e12f6969bc2656c97ad5 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Tue, 19 Apr 2022 14:13:38 -0400 Subject: [PATCH 1/3] Fix signature of random.randrange() to show multiple signatures in stub --- shared-bindings/random/__init__.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index d6aecbf322..f90d9a6e90 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -75,8 +75,13 @@ STATIC mp_obj_t random_getrandbits(mp_obj_t num_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_getrandbits_obj, random_getrandbits); -//| def randrange(stop: Tuple[int, int, int]) -> int: -//| """Returns a randomly selected integer from ``range(start, stop, step)``.""" +//| @overload +//| def randrange(stop: int) -> int: ... +//| @overload +//| def randrange(start: int, stop: int) -> int: ... +//| @overload +//| def randrange(start: int, stop: int, step: int): +//| """Returns a randomly selected integer from ``range(start[, stop[, step]])``.""" //| ... //| STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { From 3a5973084f6c972eac30171d6471b4d72b374670 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Tue, 19 Apr 2022 16:14:01 -0400 Subject: [PATCH 2/3] Add return type for 3-argument random.randrange() --- shared-bindings/random/__init__.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index f90d9a6e90..838e1e72ca 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -80,7 +80,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_getrandbits_obj, random_getrandbits); //| @overload //| def randrange(start: int, stop: int) -> int: ... //| @overload -//| def randrange(start: int, stop: int, step: int): +//| def randrange(start: int, stop: int, step: int) -> int: //| """Returns a randomly selected integer from ``range(start[, stop[, step]])``.""" //| ... //|