<p>我在python 3.5代码中使用了<code>mypy</code>,我收到了很多类似这样的消息:</p>
<blockquote>
<p>file:line number: error: Need type annotation for variable</p>
</blockquote>
<p>但是我在<code>python 3.6</code>中读到了新特性,它只在<code>python 3.6</code>中引入了变量注释的语法:</p>
<blockquote>
<p>PEP 484 introduced the standard for type annotations of function parameters, a.k.a. type hints. This PEP adds syntax to Python for annotating the types of variables including class variables and instance variables...</p>
</blockquote>
<p>如果我试图在<code>python 3.5</code>程序中向变量添加变量类型注释,它会抛出<code>SyntaxError</code>。</p>
<p>我该怎么办?忽略此消息?更新到<code>python 3.6</code>?为什么<code>mypy</code>像用<code>python 3.6</code>编写一样编译我的代码?</p>