How to tell pycharm the type of a index variable when looping

Answered

Let's say I am looping through a list of objects:

for object in objects:
    # do something

Is there some way I can inform pycharm as to the type of object so that I get the method auto-completion pops up?

 

0
2 comments

You can use one of the flavors of Python type hinting. What version of Python are you using?

0

Type hinting in 2.x  example I used recently.

self._children = []
""":type: list[TestResult]"""
0

Please sign in to leave a comment.