In the previous thread about reveal_type(), several people proposed also adding `typing.reveal_locals()`. In this thread I'd like to iron out any details and make sure we're all in agreement.
# Specification
We will add a new function `typing.reveal_locals()` with the following signature:
def reveal_locals() -> None: ...
At runtime, this function will do nothing.
When a type checker encounters a call to reveal_locals(), it will emit the types of all variables in the local scope. For example:
def f() -> None:
a = 1
b = "x"
reveal_locals()
When typechecked, this may produce:
# Motivation
# Open questions
What should the runtime behavior be? We could do something like sys._getframe(1).f_locals to get the calling function's locals and print them, but that isn't code I'd like to write.
_______________________________________________