lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
386 stars 47 forks source link

(Re-)Allow partials, lambdas etc to be used in `subgroups`. #195

Closed lebrice closed 1 year ago

lebrice commented 1 year ago

Is your feature request related to a problem? Please describe.

In #185, I significantly reworked the subgroups feature. In order to keep the size of the PR under control, I had to make a few simplifying assumptions, namely:

Describe the solution you'd like

Allow passing, at the very least:

Additional context Subgroups also work really nicely in conjunction with the Partial classes of #156. These currently are just dataclasses, so they can be used with subgroups.

lebrice commented 1 year ago

Note: This issue was created in response to another one here: #191

I've now allowed functools.partial objects to be used in the subgroups dict. This should make it much easier to configure different versions of the same dataclass. https://github.com/lebrice/SimpleParsing/pull/196#issue-1529939433

lebrice commented 1 year ago

I don't currently see a good reason to use lambdas in subgroups. The one use that makes sense is for the default_factory. But for now, I'm still disabling it, for the reasons mentioned in #196.

Closing this for now, but if anyone has an issue with this, please feel free to reopen and we'll discuss this.