title: Python dataclass: can you set a default default for fields?
body: <p>I want to make a dataclass base class where all the fields in subclasses are automatically Optional and default to None (if no default is provided).</p>
  
  <p>The following code... almost seems to do what I want, but not quite. It errors out the same way as though I'd never written the <code>__init_subclass__</code> (i.e. complains about unfilled parameters)... perhaps because my code is running <em>after</em> the dataclass magic happens?</p>
  
  <pre><code>@dataclass(order=True, frozen=True)
  class BaseDictKey:
      def __init_subclass__(cls, *args, **kwargs):
          super().__init_subclass__(*args, **kwargs)
          # noinspection PyUnresolvedReferences
          for field in cls.__dataclass_fields__.values():
              field.default = None if field.default is None else field.default
              field.type = typing.Union[field.type, NoneType]
  
  @dataclass(order=True, frozen=True)
  class ScoreDictKey(BaseDictKey):
      catalog: str  # magically becomes catalog: Optional[str] = None
      dataset: str = 'foo'  # magically becomes dataset: Optional[str] = 'foo'
  
  </code></pre>
  
  <p>(In case you're wondering why I want this, I have another baseclass that uses these BaseDictKeys that expects any and all fields in subclasses to be Optional. I suppose I <em>could</em> instead raise an exception if I detect something isn't an Optional, but that seems uglier.)</p>
  
  <p>Is this possible in Python 3.7+?</p>