Using type hints on an array function input

Viewed 73

I recently read this post which talks about using an array as a function input, and was just wondering if it was possible to use type hints to hint that the array is meant to be an array of str?

for example:

def sterileInput(options = []) -> str:
                          # ^ I want to hint that this array contains strings
    pass
1 Answers

You can use the typing module

from typing import List
def sterileInput(options = List[str]) -> str:
    pass
Related