on-internet
← Community

What is the point of reveal_type?

Stack Overflow ·

Most type checkers support reveal_type(expr)*, to show the inferred type of expr: typing.reveal_type(obj, /) Ask a static type checker to reveal the inferred type of an expression. [...] Most type checkers support reveal_type() anywhere, even if the name is not imported from typing. I don't understand its purpose. Can't I just write expr? In either case, I hover over expr in my IDE to see its inferred type: value = 10 value # (variable) value: Literal[10] reveal_type(value) # Type of "value" is "Literal[10]" Is there a difference? Why is there a need for reveal_type()? * Note: I'm not asking a

Comments

Sign in or sign up to comment and upvote.

No comments yet.