Open
Conversation
This commit fixes two issues: 1. Makes subgroups work properly when values are provided through config files. - Recognizes when fields in a config belong to a default subgroup type - Properly associates fields with the correct subgroup 2. Improves subgroup callable handling: - Better support for functions/callables that return dataclasses - Resolves function return type annotations more reliably - Fixes tests with nested class definitions 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
Owner
|
Hey there @tcapelle , thanks a lot for this! I'm going to take a look at the code and I'll get back to you. Also, do you mind if I push some changes to your branch? |
Author
|
go ahead! thanks for looking at this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a standing issue fix: #331
We successfully fixed the issue where subgroups didn't work correctly when parameters were provided through config files. The core problem was that when subgroup parameters were specified in a YAML file, they
couldn't be properly associated with their parent subgroup type.
The Fix
The solution involved two main components:
- Added code to detect when fields in a config file match fields in a subgroup's default type
- When matching fields are found, they're automatically associated with the correct subgroup
- This happens in both dataclass_wrapper.py and parsing.py when processing configs
- Enhanced how we handle functions and functools.partial objects in subgroups
- Added robust resolution of return type annotations to better support nested class definitions
- Fixed edge cases with string annotations by evaluating them in the correct scope
Before vs After
Before:
After:
Both approaches now work equivalently:
CLI args
Config file
The fix preserves backward compatibility while adding the ability to specify subgroup parameters directly in config files without explicit nesting, making the API more intuitive and consistent.
Mostly authored by Claude Code 3.7