Сокращенный пример :
Код: Выделить всё
#!/usr/bin/env python3.5
from collections import OrderedDict
# this works
def foo() -> OrderedDict:
result = OrderedDict() # type: OrderedDict[str, int]
result['foo'] = 123
return result
# this doesn't
def foo2() -> OrderedDict[str, int]:
result = OrderedDict() # type: OrderedDict[str, int]
result['foo'] = 123
return result
print(foo())
Код: Выделить всё
Traceback (most recent call last):
File "./foo.py", line 12, in
def foo2() -> OrderedDict[str, int]:
TypeError: 'type' object is not subscriptable
Что является причиной этого?
Подробнее здесь: https://stackoverflow.com/questions/412 ... annotation