How to use type hints in python 3.6?
<p>I noticed Python 3.5 and Python 3.6 added a lot of features about static type checking, so I tried with the following code (in python 3.6, stable version).</p>
<pre><code>from typing import List

a: List[str] = []
a.append('a')
a.append(1)
print(a)
</code></pre>
<p>What surprised me was that, Python didn't give me an error or warning, although <code>1</code> was appended to a <code>list</code> which should only contain strings. <code>Pycharm</code> detected the type error and gave me a warning about it, but it was not obvious and it was not shown in the output console, I was afraid sometimes I might miss it. I would like the following effects:</p>
<ol>
<li>If it's obvious that I used the wrong type just as shown above, throw out a warning or error.</li>
<li>If the compiler couldn't reliably check if the type I used was right or wrong, ignore it.</li>
</ol>
<p>Is that possible? Maybe <code>mypy</code> could do it, but I'd prefer to use Python-3.6-style type checking (like <code>a: List[str]</code>) instead of the comment-style (like <code># type List[str]</code>) used in <code>mypy</code>. And I'm curious if there's a switch in native python 3.6 to achieve the two points I said above.</p>