Replies: 3 comments 3 replies
-
The If you use a type checker in your code editor rather than running it as a command-line tool, you can get "live" feedback about a symbol's type simply by hovering over it with your mouse pointer. Mypy wasn't designed for use a language server, but pyright (the type checker I work on) is designed for this use. This eliminates the need for using I'll also note that I generally recommend against using |
Beta Was this translation helpful? Give feedback.
-
I wasn't around when |
Beta Was this translation helpful? Give feedback.
-
Currently, I write (reveal_type(c) if typing.TYPE_CHECKING else None) Does this statement have any issue in production? |
Beta Was this translation helpful? Give feedback.
-
If you need to know what the exact type of a variable is by type inferencing, you need to use
typing.TYPE_CHECKING
:Why not using comment style, just like a hint for linter?
To turn off mypy function call, just make the comment from
# typecheck::
to#! typecheck::
Why do we need an
if typing.TYPE_CHECKING
statement for mypy?Beta Was this translation helpful? Give feedback.
All reactions