xxxxxxxxxx
from typing import List
def my_func(l: List[int]):
pass
xxxxxxxxxx
from typing import List
# Define a list of integers
my_list: List[int] = [1, 2, 3, 4, 5]
# Define a list of strings
another_list: List[str] = ["apple", "banana", "cherry"]
# Define a list of tuples
tuple_list: List[tuple] = [("John", 25), ("Lisa", 30), ("Mark", 27)]
xxxxxxxxxx
# use typing.Literal - mode expects either 'a' or 'b'
from typing import Literal
def func(mode: Literal['a', 'b'] = 'a'):
if mode not in ['a', 'b']:
raise AttributeError('Not OK')