Repository navigation
Apply only passed arguments and warn about skipped fields on use - #45
Merged
Merged
Conversation
parse_extra_args_model warned at parse time about each field it could not map to an argument, including empty lists of models, so a plugin built on it printed the same warnings in each build. The reasons are now logged at debug level, and a warning is printed only when an argument for a skipped field is passed. It also applied the default of each argument that was not passed. That reset a falsy value on the instance to the field default, replaced indexed list arguments with the list default, and printed a validation warning for optional dict fields. Arguments that are not passed are now left out of the parsed result. create_model_parser keeps its defaults. Lists of paths are supported like lists of strings. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Merged
3 of 11 tasks
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #45 +/- ##
==========================================
+ Coverage 83.60% 84.52% +0.92%
==========================================
Files 3 3
Lines 372 420 +48
Branches 93 94 +1
==========================================
+ Hits 311 355 +44
- Misses 35 38 +3
- Partials 26 27 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
Three changes to
parse_extra_args_model, found through the warnings hatch-cpp prints in each build:libraries,artifacts). A plugin user cannot act on that. The reason is now logged at debug level, and the warning is printed only when an argument for that field is passed, for example--artifacts.0.name x. The message text is unchanged.flag: bool = Trueset toFalsecame back asTrue), an indexed list argument such as--values.0 9was overwritten by the list default, and optional dict fields printedFailed to validate field. The parser used for a model now leaves unpassed arguments out of the result.create_model_parserstill returns a parser with defaults.list[Path]is handled likelist[str].With hatch-cpp 0.6.0, a
librariesbuild goes from 5 warnings to 0 and a CMake build from 3 to 0. The hatch-cpp test suite passes against this branch.hatch-build has a test that expects the old warnings without passing the arguments. python-project-templates/hatch-build needs its test updated before a p2a release with this change.
Type of Change
Checklist
make lint)make test)