You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
braindevices
changed the title
help message of sub model in basesetting do not should the proper default value if the field of the sub model does not have default
help message of sub model in basesetting do not show the proper default value if the field of the sub model does not have default
Aug 8, 2024
braindevices
changed the title
help message of sub model in basesetting do not show the proper default value if the field of the sub model does not have default
help message of sub model in basesetting do not show the proper default value if the top field has a default
Aug 8, 2024
@hramezani, no, I've opened the PR. This is the fix I was discussing in #347, where the CLI will now properly display the defaults:
options:
-h, --help show this help message and exit
--v0 str (default: ok)
sub_model options:
--sub_model JSON set sub_model from JSON string
--sub_model.v1 str (default: top default)
--sub_model.v2 bytes (default: b'hello')
--sub_model.v3 int (default: 3)
However, without fixing #347, it will not function properly:
sys.argv= [
'example.py',
'--sub_model.v1=oops',
]
Settings()
"""pydantic_core._pydantic_core.ValidationError: 1 validation error for Settingssub_model.v3 Field required [type=missing, input_value={'v1': 'oops'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.7/v/missing"""
It show help:
This is apparently wrong, because the default values:
The help message should use the actual top level default values instead of the sub model's own default values.
We expect:
The text was updated successfully, but these errors were encountered: