說我有以下代碼。爲什麼Pylint會在這個raise語句中給出錯誤E0702,引發NoneType?
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的不無之間,不,我不能在那裏引發異常,因爲這發生在另一個對它有限制的線程中。
同時 「pylint的:禁用,味精= E0702」 已被棄用(只是用 「pylint的:禁止= E0702」 來代替)。 – antred 2016-04-18 08:22:04