2017-10-04 53 views
-1

我有這樣的代碼:如何處理子模塊上未使用的Pylint導入消息?

import pyqtgraph as pg # Short name cause pyqtgraph is looong 
import pyqtgraph.exporters 

# ... some code 

pg.foo() 
pg.exporters.ExportItem(blah) 

現在pylint的埋怨import pyqtgraph.exporters說這是未使用的導入。什麼是Pythonic或優雅的解決方案來解決這個警告?

請注意,如果沒有import pyqtgraph.exporters,則無法調用該子模塊中的方法。

+0

可能重複[是否可以忽略一個特定的行與pylint?](https://stackoverflow.com/questions/28829236/is-it-possible-to-ignore-one-single-specific-line -with-pylint的) –

回答

0

你可以做這樣的事情:

import pyqtgraph as pg # Short name cause pyqtgraph is looong 
import pyqtgraph.exporters # pylint: disable=unused-import 

# ... some code 

pg.foo() 
pg.exporters.ExportItem(blah) 

爲了防止pylint的警告。