-
Notifications
You must be signed in to change notification settings - Fork 52
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
Bug with template OneOf() #88
Comments
Hmm; thanks for pointing this out. Here's a short little script to demonstrate the problem: import confuse
config = confuse.Configuration('foo')
config.add({ 'import_write': 'qux' })
print(config['import_write'].get(confuse.OneOf(['ask', 'skip']))) Looking at the code, I have realized that I have no idea how OneOf is supposed to work. It was introduced in 473bc036 and it has had several strange things from the beginning. The salient weirdness is this exception handler: Lines 1392 to 1393 in 3bf9680
I don't think we should be handling that root exception at all, but silently Line 1363 in 3bf9680
I don't really understand what that Finally, this special handling of filenames in OneOf: Lines 1374 to 1375 in 3bf9680
seems pretty weird—why would these two templates need to interact in a special way? Anyway, it seems like OneOf might need to be rethought from the ground up. (And of course we should add a test case to catch this bug!) |
Hi, I got to this issue while searching for better usage examples of confuse.OneOf() and templates. I was sure I was doing something wrong. I tested by changing a config value to a non-Integer, and tested using confuse.Integer(): It worked. So I am here to confirm that OneOf() is indeed not working, but I got a day or two too late. PS: This library is awesome, btw. My project Hume will benefit a lot from it. Thanks. |
Dear Adrian,
first of all I would like to say Thank you for this awesome package.
It is really great.
Maybe I was not enough thorough but
'import_write': confuse.OneOf([bool, 'ask', 'skip']),
allows me to use such a values likeimport_write: asdfasdfasdf
inconfig_default.yaml
.The example is the
example
of package so you can reproduce it by yourself.What do I do wrongly?
Thanks for your help in advance.
The text was updated successfully, but these errors were encountered: