How to apply typing to python destructuring assignment

Viewed 104

How can I add typing to a destructuring assignment in python 3?

This example assignment, does not work because a:int, b:int = return_tuple() is not valid:

from typing import Tuple

def return_tuple() -> Tuple[int, int]:
    return 0, 0
        
a:int, b:int = return_typle()

We can see this is not valid because running mypy returns

foo.py:7: error: invalid syntax
Found 1 error in 1 file (checked 1 source file)
0 Answers
Related