我运行 pylint -E
作为我的 Python 项目测试的一部分,以确保错误不会蔓延到未经测试的代码中。通常这很有效。但最近我遇到了 voluptuous 的问题和皮林特。
问题在于 pylint 认为 voluptuous Schemas 返回的值是列表,而事实并非如此。这是一个玩具程序:
import voluptuous
MyType = voluptuous.Schema({
'q': str
})
def foo(bar):
bar = MyType(bar)
q = bar.get('q')
print q
foo({'q': '1324'})
它运行得很好:
$ python toy.py
1234
然而,pylint 标记了 .get()
调用:
$ pylint -E toy.py
No config file found, using default configuration
************* Module toy
E: 11, 8: Instance of 'list' has no 'get' member (no-member)
如何让这个程序通过pylint -E
?
一个选择是完全忽略 voluptuous
模块,例如
$ pylint -E --ignored-modules=voluptuous toy.py
(passes)
不过,如果 pylint
能更好地理解 voluptuous
就好了。
我是一名优秀的程序员,十分优秀!