Remove parsing of command line arguments from CliSettingsSource.__init__.#656
Conversation
|
Thanks @trygve-baerland for the PR. @kschwab can you take a look at this PR? |
|
Hey @trygve-baerland thanks for the PR. I agree with your intent. I think the case where this matters is during I would revert the above and original changes, as they are still breaking. However, I think the best place to address this is here, where if we get a CLI source from custom_cli_source = [source for source in sources if isinstance(source, CliSettingsSource)]
if not custom_cli_source:
# etc
elif cli_parse_args and not custom_cli_source[0].env_vars:
custom_cli_source[0](args=cli_parse_args)
# etc |
|
Thank you for your feedback, @kschwab. I think your approach makes a lot of sense. It also has the added benefit of being less prone to unintended side effects, which is what got us here in the first place :) EDIT: I am totally fine with still doing the revert, but I don't see how these changes breaks backwards compatability. Not saying I'm at all certain it doesn't, just that I don't see it. |
0ac208c to
1686aec
Compare
|
Thanks @trygve-baerland for the update. I merged my PR. |
Which should be respected when in settings_customise_sources. Co-authored-by: karta9821<[email protected]>
Co-authored-by: kschwab<[email protected]>
|
Super, @hramezani ! I've rebased onto |
|
Looks good! Thanks @trygve-baerland for the changes. |
|
Thanks all π |
As part of the discussions in #610 and #654 , PR #611 needs to be reverted due to breaking backwards compatability. In particular, it stems from
CliSettingsSource.__init__eagerly parsing command line arguments when passed withcli_parse_args.This PR is meant as an alternative solution to the problem:
_load_env_varsinCliSettingsSource.__init__is removed.CliSettingsSource.env_varsput in places where the caller needs the arguments to have been parsed. As far as I found, this turned out to be during serialization (inCliSettingsSource._serialized_args), and duringCliSettingsSource.__call__.