Короткий ответ: SyntaxError: неверный синтаксис, так как для типа python2.7 намек является нарушение синтаксиса, вы можете использовать либо Python3 или типа использования подсказки для python2.7 в комментариях как PEP предлагает
Вы можете прочитать это, чтобы знать, как делать подсказки типа в python2.7 Suggested syntax for python2.7 and straddling clode.
Some tools may want to support type annotations in code that must be compatible with Python 2.7. For this purpose this PEP has a suggested (but not mandatory) extension where function annotations are placed in a # type: comment. Such a comment must be placed immediately following the function header (before the docstring)
Пример:
следующий код Python 3:
def embezzle(self, account: str, funds: int = 1000000, *fake_receipts: str) -> None:
"""Embezzle funds from account using fake receipts."""
<code goes here>
эквивалентно следующему Python 2.7 кода
def embezzle(self, account, funds=1000000, *fake_receipts):
# type: (str, int, *str) -> None
"""Embezzle funds from account using fake receipts."""
<code goes here>
Python 2.7 не поддерживает тип подсказки, поэтому это недопустимый синтаксис. – kindall
Python 2.7 не поддерживает подсказки типов. – Blender