Python’s typing module provides objects for type annotations. List describes a list, while List[Scoop] indicates that every element should be a Scoop. section 9.10
Annotating a mutable dataclass attribute
from typing import List from dataclasses import dataclass, field @dataclass class Bowl: scoops: List[Scoop] = field(default_factory=list) def add_scoops(self, *new_scoops): for scoop in new_scoops: self.scoops.append(scoop) section 9.10
