From a0ea0d8ca0ad3ff8e055a30ae77a682f06ca3dfd Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Fri, 16 Jul 2021 15:24:28 +0200 Subject: [PATCH] ubuiltins: Document enumerate as a function. Though it is technically its own type in MicroPython, this change follows the CPython documentation. Essentially this just drops the class prefix and leaves everything else unchanged. This makes more sense when organizing this module by classes and functions. It's also a bit more logical since the equivalent example we provoide is a function definition, not a class definition. --- src/ubuiltins/__init__.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/ubuiltins/__init__.py b/src/ubuiltins/__init__.py index 237aa52..9391d8b 100644 --- a/src/ubuiltins/__init__.py +++ b/src/ubuiltins/__init__.py @@ -233,29 +233,30 @@ def divmod(a, b): """ -class enumerate: - @overload - def __init__(self, iterable: Iterable) -> None: - ... +@overload +def enumerate(iterable: Iterable) -> Iterable: + ... - @overload - def __init__(self, iterable: Iterable, start: int) -> None: - ... - def __init__(self, *args) -> None: - """ - Returns an enumerate object. +@overload +def enumerate(iterable: Iterable, start: int) -> Iterable: + ... - Equivalent to:: - def enumerate(sequence, start=0): - n = start - for elem in sequence: - yield n, elem - n += 1 +def enumerate(*args) -> Iterable: + """ + Returns an enumerate object. - .. note:: This type is not available on the BOOST Move hub. - """ + Equivalent to:: + + def enumerate(sequence, start=0): + n = start + for elem in sequence: + yield n, elem + n += 1 + + .. note:: This type is not available on the BOOST Move hub. + """ @overload