markfink / whaaaaat

Inquirer.js port to Python (https://www.npmjs.com/package/inquirer). people blame me for staling this project. I do not have time to work on this right now - whaaaaat do you want me to do? take it offline?
MIT License
83 stars 9 forks source link

Undefined variable #3

Closed lelit closed 7 years ago

lelit commented 7 years ago

At line 43 of rawlist.py there is a reference to key: as there's no examples of passing a plain string as a choice, I could not figure out a reasonable fix, or make sense of the following key += 1 instruction.

markfink commented 7 years ago

just to make sure... you refer to a fix but there is no problem related to this? -> so I gave the question label. from examples/rawlist.py

    {
        'type': 'rawlist',
        'name': 'theme',
        'message': 'What do you want to do?',
        'choices': [
            'Order a pizza',
            'Make a reservation',
            Separator(),
            'Ask opening hours',
            'Talk to the receptionist'
        ]
    },

rawlist uses index numbers to select a choice. Seperators() would make a gap in the numbering so we keep track (with key). key += 1 only for choices (basestrings)

$ python examples/rawlist.py
lelit commented 7 years ago

My bad, you're right, who knows what I was thinking, sorry for the noise 😃

lelit commented 7 years ago

Ah, I found the glitch: the problem is actually in expand.py, not rawlist.py!

markfink commented 7 years ago

now I see, looks like you are right. this is probably a c&p "leftover". Does not look very disturbing but also not very reassuring. Let me take another look with a fresh eye tomorrow. I probably just remove it and see what happens. Thank you for your useful input!

markfink commented 7 years ago

fixed with https://github.com/finklabs/whaaaaat/commit/1e682bc772c56f541b6c41f8a7ae3aeb14a87651

lelit commented 7 years ago

What does it mean when an item in the incoming choices is a plain string, and when can it happen? I ask because I still see the chance that this line being executed before key is assigned...