Suppose we want to add type hinting to a function that adds a bunch of integers together using a starred argument:
def add_integers(*integers):
return sum(integers)
Is the correct practice to give the integer type, since that's what each individual argument will be?
def add_integers(*integers: int):
return sum(integers)
...or to give the type of the resulting variable, which ends up being a sequence (tuple) of integers?
def add_integers(*integers: Sequence[int]):
return sum(integers)