I have such a method:
def select_unassigned_variable(self, variables: List[V]) -> Optional(V):
I want this to return something of type V
or None
in some cases.
But I get such error:
TypeError: Cannot instantiate typing.Optional
What should I change?
Advertisement
Answer
You need to use it with brackets instead of parentheses:
def select_unassigned_variable(self, variables: List[V]) -> Optional[V]:
like you did with List
.