如何让 PyCharm 在方法中自动完成代码? [英] How to get PyCharm to auto-complete code in methods?
本文介绍了如何让 PyCharm 在方法中自动完成代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用第 3 方时 l诸如
def some_method(self, conn):"""@type conn:EC2Connection"""conn.<自动完成>
When I'm using a 3rd party l ibrary such as boto, PyCharm seems to be able to auto-complete quite nicely
However, as soon as I define a function of my own, auto-complete breaks down inside that function. I understand why, since I can't give the function any type information about its arguments, so it can't guess how to auto-complete. Is there a way around this issue?
Edit
I tried using the docstring (for Python 2), but still no auto-complete
def delete_oldest_backups(conn, backups_to_keep, backup_description):
"""
delete_oldest_backups(EC2Connection, int, string)
"""
(Also tried boto.ec2.connection.EC2Connection
instead of just EC2Connection
)
解决方案
You can use type hints: http://www.jetbrains.com/pycharm/webhelp/type-hinting-in-pycharm.html
def some_method(self, conn):
"""
@type conn: EC2Connection
"""
conn.<autocomplete>
这篇关于如何让 PyCharm 在方法中自动完成代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文