Open bhaveshpraveen opened 4 years ago
This is linked to issue https://github.com/python-poetry/poetry/issues/2358
This is the existing code snippet of the validate() in SelectChoiceValidator present inclikit/ui/components/choice_question.py
validate()
SelectChoiceValidator
clikit/ui/components/choice_question.py
if value < len(self._values): result = self._values[value] else: result = False
So, if the user entered -3 as the input for a choice question, then it's still taken as a valid choice because Python supports negative indexing.
This might lead to inconsistencies.
Simple solution would be to modify the above condition to something like this
if 0 <= value < len(self._values): result = self._values[value] else: result = False
I've added a draft PR. Please let me know what you think.
Since https://github.com/sdispater/clikit/pull/27 has been merged, it seems that this issue can be closed.
This is linked to issue https://github.com/python-poetry/poetry/issues/2358
This is the existing code snippet of the
validate()
inSelectChoiceValidator
present inclikit/ui/components/choice_question.py
So, if the user entered -3 as the input for a choice question, then it's still taken as a valid choice because Python supports negative indexing.
This might lead to inconsistencies.
Simple solution would be to modify the above condition to something like this