
Am 23.01.22 um 01:14 schrieb Jelle Zijlstra:
I realize I never responded to this suggestion.
Sebastian had a similar idea in https://github.com/python/typing/issues/277#issuecomment-961061916: use the warnings module to emit a message.
Personally I don't care much for the exact runtime behavior, but I'm wary of making it too complicated. I don't feel like tracking down where a call comes from is a very compelling use case: it's easy to just grep for, and your type checker should give you an error for any call to reveal_type() anyway.
One advantage of using the warnings module is that it integrates well with existing testing tooling. For example, you could configure pytest to show or not show reveal_type() output, or even to throw an error. - Sebastian