[英]How to deal with Pylint unused import message on submodule?
我有以下代碼:
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
說它是未使用的導入。 解決此警告的Python或優雅解決方案是什么?
請注意,如果沒有import pyqtgraph.exporters
,則無法調用該子模塊中的方法。
您可以執行以下操作:
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警告。
這應該工作
import pyqtgraph as pg # Short name cause pyqtgraph is looong
from pyqtgraph import exporters
# ... some code
pg.foo()
exporters.ExportItem(blah)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.