memo: dict[int, int] = {0: 0, 1: 1} # *our base cases*
возвращает следующую ошибку:
TypeError: 'type' object is not subscriptable
memo: dict[int, int] = {0: 0, 1: 1} # *our base cases*
возвращает следующую ошибку:
TypeError: 'type' object is not subscriptable
Я думаю, вы должны использовать Dict
, например:
from typing import Dict
memo: Dict[int, int] = {0: 0, 1: 1}
В вашем случае вы использовали dict
типа type
>>> type(dict)
<class 'type'>
>>> type(Dict)
<class 'typing._GenericAlias'>
Вы можете сделать что-то вроде:
from typing import Dict
mydict = Dict[int, int]
mydict = {0: 0, 1: 1}
Результат:
>>>mydict
{0: 0, 1: 1}
Если это то, что вы хотели.