Search code examples
pythonvisual-studio-codepycharm

How to add type hints in PyCharm?


I often find myself having to start a debugging session in PyCharm only in order to inspect a variable and look up its class with something.__class__ so that I can insert the type hint into the code in order to make it more readable.

Is there a way to do it automatically in PyCharm via a context action, in VSCode or maybe some other tool?


Solution

  • Have you tried Adding type hints in the PyCharm?

    enter image description here

    The VSCode-Python has not supported this feature, and I have submitted a feature request on GitHub.