使用python3,我们不再需要在调用super时显式设置父类:

def __init__(self):
    super().__init__()

但似乎PyCharm并不知道这一点,因为当我try 为某个方法自动完成super时,它使用的是旧样式,我收到了这样的消息:

def setUp(self):
    super(AutocompleteTestCase, self).setUp()

Is there any way to tell PyCharm to use new style, because I could not find one.
Editor -> General -> Code Completion doesn't provide any way to add/override custom rules.

推荐答案

super活动模板在PyCharm(the corresponding ticket in PyCharm's issue tracker)中已过时.

我想你可以在Preferences/Settings | Editor | Live Templates | Python | super分钟内手工编辑.

enter image description here

Python相关问答推荐

将jit与numpy linSpace函数一起使用时出错

Python库:可选地支持numpy类型,而不依赖于numpy

NP.round解算数据后NP.unique

PyQt5,如何使每个对象的 colored颜色 不同?'

对象的`__call__`方法的setattr在Python中不起作用'

在ubuntu上安装dlib时出错

在matplotlib中删除子图之间的间隙_mosaic

python panda ExcelWriter切换动态公式到数组公式

如何在Great Table中处理inf和nans

如何在FastAPI中替换Pydantic的constr,以便在BaseModel之外使用?'

Tensorflow tokenizer问题.num_words到底做了什么?

提取数组每行的非零元素

如何在验证文本列表时使正则表达式无序?

如何使用matplotlib查看并列直方图

Python协议不兼容警告

为什么后跟inplace方法的`.rename(Columns={';b';:';b';},Copy=False)`没有更新原始数据帧?

浏览超过10k页获取数据,解析:欧洲搜索服务:从欧盟站点收集机会的微小刮刀&

遍历列表列表,然后创建数据帧

如何将列表从a迭代到z-以抓取数据并将其转换为DataFrame?

如何在表单中添加管理员风格的输入(PDF)