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
128: Allow the user to cancel interactive mode #190
128: Allow the user to cancel interactive mode #190
Conversation
current_node.label, | ||
chain[i - 1].left_hand_side | ||
) | ||
).lower() | ||
if user_says.startswith('s'): | ||
interactive = False |
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 don't think you need the interactive = False
assignment because you're returning.
We could make it so that for other vulnerability chains as well, it doesn't ask for user input anymore. But I think this change is definitely good and a step in the right direction, I'm happy to merge :D (fwiw I don't think my comment on the issue was very clear.) |
That's a good point. I can make that change so that we stop it for all chains. |
So the last commit stops asking for all chains, but I'm not 100% satisfied. There aren't many better options without touching too much (e.g. making an Interactive/Mode object, or a Config object and making interactive one of its elements). This is easy but inelegant. I have not fixed Travis' complaints about too many returns inside that function. While that is true, refactoring this function isn't trivial so I'd like to get some input on what's the preferred path forward, both for Travis and the general solution. |
I agree it's inelegant, but it's good code 👍 Maybe in the >>> class Interactive(): # Maybe in `vulnerability_helper.py`
... def __init__(self):
... self.on = False
... def __bool__(self):
... return self.on
...
>>> interactive.on = interactive_mode # Where we currently do `interactive = False` Where we rename the Code Climate complains about a lot of things in the existing code, I don't know if there's anything we can do in this case. |
(Gonna go ahead and merge 👍 , if that's okay, as it's good as-is.) |
Sorry, I'm having a hard time finding time lately due to some personal commitments. I was working on a nicer approach, but I'm happy to see this merged and we can improve it later. |
No worries @adrianbn 👍 Same here. |
This should resolve #128. The change is so straight forward and any potential tests would be awkward, so I'm not sure we want to include specific tests for this (there were none before for interactive mode anyway).
I'm open to suggestions though.
You can manually test this change by using this sample code:
Then
python -m pyt sample.py -m bb.txt -i
. You can see how it does as many as you want until you answers
.