title: Python convert type hint string representation (from docstring) to actual type/typing object
body: <p>I would like to know if there is an existing implementation that converts the string representation of a type hint (e.g. from a docstring) back to the type (or typing) object. Thereby arbitrary deep nested types should also be supported (see third example).</p>
  <pre class="lang-py prettyprint-override"><code>import typing import List, Optional, Union
  
  converter_function(&quot;List[str]&quot;) == List[str]
  
  converter_function(&quot;int&quot;) == int
  
  converter_function(&quot;Optional[List[Union[str, float]]]&quot;) == Optional[List[Union[str,float]]]
  
  converter_function(&quot;foobar&quot;) # Exception / None
  </code></pre>
  <p>One option would be to simply use eval, but I would like to avoid that at all costs :D</p>
  <p><strong>Edit</strong>
  As background on why I want to do this: I want to write a script that checks if a docstring matches 100% to a function, all types are correct and so on.</p>