Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing functools.partial as entries in the subgroups dict #196

Merged
merged 16 commits into from
Jan 13, 2023

Conversation

lebrice
Copy link
Owner

@lebrice lebrice commented Jan 12, 2023

Partially solves #195

  • Allows passing functools.partial objects in the subgroups dict

  • lambda expressions aren't allowed as the default_factory yet!

    • This is because we need to know what the default key is for that choice, and it isn't in the subgroup dict.
    • This is also because we can't inspect the default values for the fields without actually calling the factory.

    Therefore, you should use functools.partial for now.

Also somewhat related to #191, in that it makes this kind of thing possible again.

Future work: Integrating the Partials feature of #156 with this. This should work out-of-the box, since those are dataclasses that also inherit from functools.partial, but we'll see! :)

Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
@lebrice lebrice marked this pull request as ready for review January 12, 2023 22:53
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
@lebrice lebrice merged commit 03f23a7 into master Jan 13, 2023
@lebrice lebrice deleted the flexible_subgroups branch January 13, 2023 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Re-)Allow partials, lambdas etc to be used in subgroups.
1 participant