Allow discard_init_args_on_class_path_change
to handle more nested contexts
#248
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.
What does this PR do?
Fixes #247
While a
subclass_spec
can be either adict
orNamespace
jsonargparse/jsonargparse/typehints.py
Lines 790 to 795 in ac790ba
when entering
ActionTypeHint.discard_init_args_on_class_path_change
:jsonargparse/jsonargparse/typehints.py
Lines 295 to 310 in ac790ba
jsonargparse.typehints.discard_init_args_on_class_path_change
below currently assumes any previous value for a nested subclass will already have been cast as aNamespace
:jsonargparse/jsonargparse/typehints.py
Lines 934 to 942 in ac790ba
with
L941
resulting in:Right now, nested generic
dict
configurations like the repro case I include below don't trigger thesubclass_spec_as_namespace
Namespace
wrapping thatjsonargparse.typehints.discard_init_args_on_class_path_change
requires when removing overridden subclass spec configuration in this context.With this PR's minor patch to
jsonargparse.typehints.discard_init_args_on_class_path_change
, this use case can be accommodated. This PR also adds a test that covers the expanded support.