Fix Choice(enum) auto complete not working #3017
Conversation
|
Can you pull down 8.2.2 and see if this is fixed. It is yanked due so you will have to specify it. I think #3004 might fix this. |
|
Is 8.2.2 newer than main? I added a test case here to show the bug on main. |
|
Did not look too closely just saw the title. Looks like it was not covered by #3004. Can you please rebase onto stable. |
|
Thank you, I will rebase it next week, I currently don't have my laptop with me. |
Autocomplete on choices was not working as it didn't use the same logic to normalize it's string value.
The normalize function per default is mapping choices to lower case if case sensitivity is set to False. As the normalize function can be overwritten we have to take the value that is return by it also for autocomplete, so we need to transform the auto complete value also into lower case on default.
b618b72 to
fd7f23a
Compare
|
@Rowlando13 I rebase on master and fixed the test in the way that I think make the most sense. |
|
It does look like you fix breaks case sensitivity which does not work. I am not sure what the correct normalization path is. If you are able to figure it out, just ping me and I will take a look again. |
|
Did you take the time to fully understand my PR and what is changing? Considering that currently autocomplete for options that use a normalize function or an enum is completely broken and not usable at all I think this is the right way forward. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I understand that you're frustrated that you don't seem to be able to adequately communicate your intention to the maintainer. However, writing like this is unacceptable. If you're not being understood, take a step back until you're ready to approach your explanation again without resorting to implying that the maintainer doesn't know what they're doing. |
|
The behavior around case insensitivity and normalization is complicated, and it can be hard to dive back in and reason about it. This is true of a lot of features in Click, see our current work on flags and defaults. This change makes sense, but it's not immediately obvious. At first, seeing a test change the behavior from returning a case-sensitive display looks incorrect. If the choice is marked insensitive, then it's reasonable to think the option should be displayed as-is but matched insensitively, and that the test was correct as-is. However, after looking through more of the code to understand our past decisions, it looks like we're applying the transformation for the metavar and help text as well, so those will display normalized when case-insensitive matching is enabled. Therefore, it does make sense to apply the normalization here as well. |
Apologies if my tone was not right. |
Fully agree with this |
|
Thanks! @davidism. Also thank you @berndbohmeier for taking a step back and considering tone. To give a little more context, the team is currently working on another very large PR which will fix a lot of things for users and I did not want to pull anyone away. |
|
If you are curious it's #3030. |
|
Okay, thank you for the context. |
Autocomplete on choices with enums was not working as it didn't use the same logic to normalize it's string value.
I added a test to show the wrong behavior.
However, when I use the same normalize function I see another test failing, and I wanted to discuss. As from my understanding it is allowed to overwrite the normalize method, so I think we have to use it here, in case it is changed to custom behaviour, as whatever is autocompleted should be a valid input. But this means that default behavior would be that we autocomplete for example Fo to foo if the options are [Foo, Bar] with case insensitive, which fails an existing test and could be seen as a breaking change. Please advice, thank you.
fixes #3015