
Update: reveal_type was just merged into CPython and will be in Python 3.11. I will also provide it in the next release of typing-extensions. El lun, 24 ene 2022 a las 2:21, Sebastian Rittau (<srittau@rittau.biz>) escribió:
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
_______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: jelle.zijlstra@gmail.com