码迷,mamicode.com
首页 > Web开发 > 详细

An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)

时间:2019-07-09 13:58:18      阅读:322      评论:0      收藏:0      [点我收藏+]

标签:object   lock   efi   pytho   怎么   hidden   int   this   enc   

VS code 里写下如下代码:

class Encoder(JSONEncoder):
    def default(self, o): 
        if isinstance(o, ObjectId):
            o = str(o)
            return o

pylint 提示:

An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)

看来pylint 不怎么喜欢使用default命名我们的方法。

虽然不影响代码的运行,但对于强迫症来说,真的很烦。

修改:

class Encoder(JSONEncoder):
    def default(self, o):                     # pylint: disable=E0202
        if isinstance(o, ObjectId):
            o = str(o)
            return o

完美解决

An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)

标签:object   lock   efi   pytho   怎么   hidden   int   this   enc   

原文地址:https://www.cnblogs.com/ifengqi/p/11156630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!