autocomplete for a context manager class
Answered
Hello,
I work with IDEA/Python plugin (PyCharm) version 2016.3.163.298 and I have a Python 2.7 based project. Refactoring and autocomplete work great for all the classes except a one, using the context manager construct. I mean - a class with __enter__ and __exit__ defined and invoked the way:
with MyContextManagerClass() as mine:...
Eg.if I use the autocomplete option it presents the base Object class methods but not MyContextManagerClass methods. I need to type the method name and then it is available for navigation, debugging etc. Is it a standard behaviour of the plugin?
Please sign in to leave a comment.
Hello, Edward!
No, it should work.
> Refactoring and autocomplete work great for all the classes except a one, using the context manager construct. I mean - a class with __enter__ and __exit__ defined and invoked the way:
> with MyContextManagerClass() as mine:...
Could you please attach a code snippet with it to let us reproduce the problem in our environment? Thank you.
Hello Anna,
I found the reason of that behaviour:
in the multiline docstring of the __enter__ method there was a line beginning with :type. Removing it I got autocomplete working.
The :type hint was unnecessary there but I did not notice it earlier. I did not think it impacts the autocomplete behaviour as well.