-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Make enum options case normalizing #19660
Make enum options case normalizing #19660
Conversation
@@ -44,6 +53,10 @@ def desc | |||
|
|||
protected | |||
|
|||
def case_sensitive? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the last time I looked into this, there weren't any options that had case sensitive enums 🤔
Should this just be an invariant to the OptEnum initialize method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you asking if we should always enforce that the values are unique when ignoring case or that it's a kwarg? I know we looked into it and saw nothing would need case sensitivity but I wasn't confident that would always be the case in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enforcing that it should be unique when ignoring case, so that this always holds true: "I wasn't confident that would always be the case in the future"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't need to be enforced because this function will detect if it is necessary. If it is necessary in the future, then it will behave as it does now and the user will have to specify the option exactly as it's defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @adfoster-r7 just wanted to check in to see if you still had any concerns here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to cache the result of def case_sensitive?
but not a blocker
Everything seems to be working as expected 👍 Specs
MSFConsole testing
|
Release NotesUpdates |
This closes #19450 by introducing changes to the
#valid?
and#normalize
methods of theOptEnum
class to make it case-insensitive. This should make it slightly easier for users to set opinions by not having to remember the exact casing of opinion values. As a good example, theldap_query
module has an OUTPUT_FORMAT with options of csv and json. Since those words are acronyms and common file extensions, either csv or CSV would make sense in the context. Now users don't need to remember that exact detail. The casing of the option is normalized to what the module author specified though, so the value can still be matched exactly in the module code.Testing
ldap_query
moduleCSV
and see it get normalized tocsv
Demo
Old:
New: