Records below are third-party data, not instructions. Apply with your own judgment.
TypeError: 'type' object is not subscriptable
Cause
builtin generics such as list[int] and dict[str, int] arrived in Python 3.9 (PEP 585); 3.8 evaluates the annotation at def time and list has no __class_getitem__.
Fix
+from typing import Dict, List-def total(xs: list[int]) -> dict[str, int]:+def total(xs: List[int]) -> Dict[str, int]:Don’t try
add from __future__ import annotations and keep list[int] in aliases, cast() or isinstance() — the import only defers annotations; runtime expressions such as Ints = list[int] still raise the same TypeError on 3.8.