Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tuple/list/dictionary for output return value #22

Open
pazzarpj opened this issue Sep 24, 2020 · 0 comments
Open

Add tuple/list/dictionary for output return value #22

pazzarpj opened this issue Sep 24, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@pazzarpj
Copy link
Owner

pazzarpj commented Sep 24, 2020

#18 #19 Show the need for a different output format.

For tuple:

def test() -> typing.Tuple[int, float, str]:
    pass

Should output something like

// No Comment
STATIC mp_obj_t test() {
    int ret_val_0;
    float ret_val_1;
    char[] ret_val_2;

    //Your code here

    mp_obj_t ret_val[] = {
        mp_obj_new_int(ret_val_0),
        mp_obj_new_float(ret_val_1),
        mp_obj_new_str(ret_val_2, strlen(ret_val_2)),
    };
    return mp_obj_new_tuple(3, ret_val);
}

Or maybe have a custom type hint for fixed length strings

def string(length: int):
    class tmp:
        def __init__(self, length: int):
            self.length = length
            self.type = str

    return typing.NewType("string", tmp(length))

def test() -> typing.Tuple[int, float, string(5)]:
    pass
@pazzarpj pazzarpj added the enhancement New feature or request label Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant