title: Python: Inherit typing.Optional arguments
body: <p>I want to inherit optional arguments to another Python class using typing.Optional,
  but I can't set this attribute in the child class.</p>
  <p>I have two classes The parent class Test and the child class Test_inherit.</p>
  <p>In the parent class Test I have defined using typing.Optional a optional argument/method/attribute.</p>
  <p>If I am using this optional argument in the parent class everything is fine.
  But if I am inherit this class to a other Test_inherit I am not able to define this optional argument.</p>
  <p>Is there a way to do this?</p>
  <p>Thanks in advance.</p>
  <pre><code>from typing import Optional
  from typing import get_type_hints
  
  
  class Test:
      
      name: str
      type: str
      units: Optional[str]
      
      
      def __init__(self,name,typ_,**kwargs)-&gt; None:
          self.name = name
          self.type = typ_
          #self.units = None
          type_hints = get_type_hints(self)
          for argname in kwargs:
              #print(argname)
              type_hint = type_hints[argname]
              if hasattr(type_hint, &quot;__args__&quot;):  # For the Optional[...] types
                  type_hint = next(t for t in type_hint.__args__
                                   if not isinstance(t, type(None)))
   
              setattr(self, argname, type_hint(kwargs[argname]))
  
              
  
  class Test_inherit(Test):
      TAG: str
      symbol: Optional[str]
      
      def __init__(self,name,typ_,**kwargs)-&gt; None:
          self.TAG='Test_tag'
          super().__init__(name, typ_, **kwargs)
          
   
  test0=Test('hallo','float')   
  print(test0.name,test0.type)
  test1=Test('hallo','float',units='N')   
  print(test1.name,test1.type,test1.units)
  test2_0=Test_inherit('hallo','float')
  print(test2_0.name,test2_0.type)
  test2_1=Test_inherit('hallo','float',symbol='N')
  print(test2_1.name,test2_1.type,test2_1.symbol)
  test3=Test_inherit('hallo','float',units='N')
  print(test3.name,test3.type,test3.units)
  </code></pre>