Join GitHub today
Do semantic analysis on lambda's bodies #4257
Nov 16, 2017
Nice, but it's introducing a new form of error. Here's an example:
from typing import Callable def f() -> Callable[, int]: a = lambda: b # error: Name 'b' is not defined b = 42 return a assert f()() == 42
I wouldn't mind so much except I'm seeing this example in a few places in our existing codebase where fixing it would be somewhat awkward (the lambda is passed as a callback to something that must exist before some local variable can be set -- but the callback won't be called until after that's taken care of).
I think with PEP 526 this can be safely fixed by