Consider this example dataclass which contains a variable x
which is a list of 5 integers. What is the correct way to write the type hint? Individually specifying all 5 int
values in the list
seems cumbersome? What if my list was N
elements long and N
was very big?
@dataclass
class Example:
x: list[int, int, int, int, int] = [0, 0, 0, 0, 0]
Can I just write:
@dataclass
class Example:
x: list[int] = [0, 0, 0, 0, 0]
Or is there another way I can write the type hint to indicate to the user that this list is always 5 elements long?