-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PluginRequirements: Fix optional
and no default
value behaviour
#1142
Comments
One possible fix for this is only to set the default value if |
I'm not keen on changing this behaviour, because there may be existing plugins that expect all keys to always exist, which will then throw an exception when they don't. The configuration value is set by the plugin, so moving the default value from a It's basically two ways of doing the same thing. The current established way of doing this is that if a configuration option is defined, you can guarantee the key will be present. It should default to None, meaning that |
IMO the current implementation of an
optional
argument requirement with nodefault
value is not working as expected.For instance, if I use the following and no
--output
is used, I would expect theself.config
doesn't contain theoutput
key.So when I do this:
In HierarchicalDict::getitem() it will raise a
KeyError
exception and the getter will assign the default value.However, that is not working. The keys are created anyway, regardless of the
optional=True
and the absence of a default value.That means, in this case, calling
self.config.get("output", "foo")
from a plugin still returnsNone
.The text was updated successfully, but these errors were encountered: