Skip to content

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

Open
@pazzarpj

Description

@pazzarpj

#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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions