假设我有以下代码。
def foo():
foobar = None
if foobar is not None:
raise foobar
当我通过 pylint 运行此代码时,出现以下错误:
E0702:4:foo: Raising NoneType while only classes, instances or string are allowed
这是pylint中的错误吗?我的pylint太旧了吗?
pylint 0.18.0,
astng 0.19.1, common 0.45.0
Python 2.5.1 (r251:54863, Aug 25 2008, 09:23:26)
注意:我知道这段代码没有任何意义,它被提炼成裸露的骨头以暴露手头的问题,通常情况下发生在第 2 行和第 3 行之间,这可能使 foobar 不是 None,不,我不能只是在那里引发一个异常,因为这发生在另一个对其有限制的线程中。