Please consider the following example in Python 3.8+. Assume a function which gets any number of arguments, all of the same type. For example
def fun(*foos):
for foo in foos:
foo.do_something()
I would like to add typing for the foos
argument, for this reason assume that all arguments are of the same type foo_type
. What is the correct way for typing?
For me the following would be the obvious typing:
from typing import Tuple
def fun(*foos: Tuple[foo_type]) -> None:
for foo in foos:
foo.do_something()
My IDE (CLion) suggest:
def fun(*foos: foo_type) -> None:
for foo in foos:
foo.do_something()
Which way of typing for the foos
argument is correct, and why?