本文介绍了鼻子工具和针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用鼻子工具保持pylint快乐的正确方法是什么?
What is the right way to use nose.tools and keep pylint happy?
以下代码:
'''
This is a test
'''
import nose.tools
import nose.tools.trivial
nose.tools.assert_equal(1, 1)
nose.tools.assert_equals(1, 1)
nose.tools.trivial.assert_equal(1, 1)
nose.tools.trivial.assert_equals(1, 1)
导致以下pylint错误:
Results in the following pylint errors:
$ pylint -i y -r n /tmp/aseq.py
************* Module aseq
E1101: 8,0: Module 'nose.tools' has no 'assert_equal' member
E1101: 9,0: Module 'nose.tools' has no 'assert_equals' member
E1101: 11,0: Module 'nose.tools.trivial' has no 'assert_equal' member
E1101: 12,0: Module 'nose.tools.trivial' has no 'assert_equals' member
当然,可以禁用E1101,有没有一种更清洁的方法?
Of course, one could disable E1101, is there a cleaner way?
推荐答案
而不是禁用E1101,您应该输入:
Instead of disabling E1101, you should put:
ignored-classes=nose.tools,nose.tools.trivial
.pylintrc中[TYPECHECK]
部分下的
.
in .pylintrc, under the [TYPECHECK]
section.
在 pylint文档中,该选项对于具有以下内容的类有用属性动态设置".
As it stands in the pylint doc, this option is "useful for classes with attributes dynamically set".
这篇关于鼻子工具和针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!