Home > Blockchain >  How to automatically add type hints in PyCharm?
How to automatically add type hints in PyCharm?

Time:04-18

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?

CodePudding user response:

for Visual Studio Code this is extension for type hints: Python Type Hint , IntelliSense download this extensions and find who would you like the most . I used IntelliSense

CodePudding user response:

Is there a way to do it automatically in PyCharm via a context action

Well no! Because if you're getting a type hint of a subclass at run-time that does not mean you wouldn't want to (or should) insert the type hint of the superclass instead. (Or the type hint of an entirely different class if it's a enter image description here

  • Related