Bharel
Bharel

Reputation: 26901

How can I reveal type hints in PyCharm?

Python's mypy has a special function called reveal_type() which asks the linter to display the type of variables.

PyCharm does not support it and instead shows the function as non-existing.

How can I display the type hint of a variable?

Upvotes: 4

Views: 1604

Answers (1)

Bharel
Bharel

Reputation: 26901

By default, PyCharm binds the F1 key to the "display documentation" command.

PyCharm example screenshot

When displaying the documentation, you're able to see the type of variables, function signatures, class signatures, and docstrings.

You're also able to view the type directly using ctrl+shift+P or by hovering with the mouse and pressing ctrl.

If you do not use the default keymap, you may navigate to View | Quick documentation:

enter image description here

Upvotes: 6

Related Questions