Answers for "TypeError: '_TypedDict' object is not subscriptable"

0

TypeError: '_TypedDict' object is not subscriptable

You can't subscript TypedDict; you're meant to instantiate or subclass one according to the docs:

Point2D = TypedDict('Point2D', x=int, y=int, label=str)
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
With that in mind, you can just inline that in your signature:

def x(a: TypedDict('A', x=int)):
  pass
Posted by: Guest on September-02-2020

Code answers related to "TypeError: '_TypedDict' object is not subscriptable"

Python Answers by Framework

Browse Popular Code Answers by Language