title: Dynamically create function with typehint in memory
body: <p>I'd like to dynamically create a function in memory, with a type hint of the argument. I do have some working code, but it feels extremely hacky and fragile.</p>
  <pre class="lang-py prettyprint-override"><code>import typing
  
  func_name = 'some_function_name'
  req_type=int
  
  a = None
  exec(f'''def {func_name}(my_argument:{req_type.__name__}): pass
  a = {func_name}''')
  
  print(a) # &lt;function some_function_name at 0x000001B89F3311F0&gt;
  print(typing.get_type_hints(a)) # {'my_argument': &lt;class 'int'&gt;}
  </code></pre>
  <p>There has got to be a better way to do this. Any suggestions?</p>