Given this function:
def array_returner():
return ["hello", "there"]
How would I typehint that this function returns an array of strings, without importing List (and using the List[str] syntax)?
Like this
from typing import List
def array_returner() -> List[str]:
pass
Since python3.9
def array_returner() -> list[str]:
pass
This is what you're looking for:
from typing import List
def array_returner() -> List[str]:
return ["hello", "there"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With