An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)
Posted ifengqi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)相关的知识,希望对你有一定的参考价值。
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)的主要内容,如果未能解决你的问题,请参考以下文章
PB data window 窗口报错提示:an arggument used in the select is not defined 为啥会报错,怎么解决
Cannot refer to a non-final variable file inside an inner class defined in a different method
java关于Cannot refer to the non-final local variable list defined in an enclosing scope解决方法
215. Kth Largest Element in an Array 第K大的数
The JVM found at JAVA_HOME is damaged.Please reinstall or define EXE4J_JAVA_HOME to point to an inst