My IDE is warning me against a possible variable reference before assignment. But I'm having trouble spotting it. I'm ready to turn in a bug report, but maybe you can see what I'm not seeing.
The variable in question is a named check_dialog
and the reference before assignment warning happens at the end of the following code snippet in the line I marked for you:
if dialog:
validate = None
string = False
if dialog == Prompt.YES | Prompt.NO:
check_dialog = lambda c: chr(c) in 'yn'
elif dialog == Prompt.CONTINUE | Prompt.QUIT:
check_dialog = lambda c: chr(c) in 'cq'
elif dialog == Prompt.YES | Prompt.NO | Prompt.QUIT:
check_dialog = lambda c: chr(c) in 'ynq'
else:
raise ValueError('Invalid dialog argument.')
answer = None
while not answer:
self.addstr(0, 1, prompt)
if string:
curses.curs_set(True)
curses.echo()
answer = self.getstr(1, 3)
curses.noecho()
curses.curs_set(False)
elif dialog:
while not check_dialog(answer): # warning here!
answer = self.getch()
else:
answer = self.getch()