Idea: Refactoring of the `FieldWrapper` class
Would be a good idea to refactor the FieldWrapper class a bit.
The args_dict (a dict of all the argparse arguments for a given field, that get passed to parser.add_arguments in the FieldWrapper) is currently created using a mix of three things (with increasing priority):
- The type annotation of the field
- The dataclass context (e.g. when adding an Optional[Dataclass] field on another dataclass, or when using the
defaultorprefixarguments toparser.add_arguments, etc. - The manual overrides (arguments of
parser.add_argumentpassed to thefieldfunction)
These three are currently a bit mixed together in the FieldWrapper class. It would perhaps be preferable to have them be cleanly separated.
Yeah, it needs some love. I find it especially limiting that DataclassWrapper/FieldWrapper do too much by themselves and so injecting new information into the process is hard (e.g. creating a feature that has an effect at the field level but is specified as an argument to add_arguments())