โ SANDBOX VERIFIED (99% Confidence)
python
ID: rec_0c14d6a12a42
TypeError: 'type' object is not subscriptable
Before Python 3.9, the built-in types list, dict, tuple, set etc. could not be used directly in type annotations with subscripts (list[str]). Code that uses the new syntax fails on 3.8 and earlier with this error. The typing module equivalents must be used instead.
๐ก Verified Solution
On Python < 3.9 use from typing import List, Dict, Tuple, Set, Optional, Union. On 3.9+ the built-in generics are preferred.
Patch / Unified Code Diff:
--- old.py (fails on 3.8)
+++ new.py (compatible)
@@ -1,3 +1,4 @@
-def process(items: list[str]) -> dict[str, int]:
+from typing import List, Dict
+def process(items: List[str]) -> Dict[str, int]:
...
Official Primary Reference:
https://docs.python.org/3/library/typing.html#typing.List
๐งช Sandbox Execution Evidence
Exit Code: 0
Tests Passed: 1 / 1
Confidence: 99%
Protocol: MCP 2026
Integrate this knowledge into your AI agent stack
Connect the canonical endpoint https://mcp.synapsemesh.dev in Claude, ChatGPT, or Cursor.