0

I have this code:

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

# ... some code

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

Now pylint complains about the import pyqtgraph.exporters saying it is unused import. What is the Pythonic or elegant solution to fix this warning?

Note that without having import pyqtgraph.exporters, the methods in that submodule cannot be called.

Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
  • Possible duplicate of [Is it possible to ignore one single specific line with pylint?](https://stackoverflow.com/questions/28829236/is-it-possible-to-ignore-one-single-specific-line-with-pylint) – Ignacio Vergara Kausel Oct 04 '17 at 09:13

2 Answers2

3

You can do something like that:

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)

To prevent pylint warnings.

Antonio S.
  • 66
  • 2
0

This should work

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

# ... some code

pg.foo()
exporters.ExportItem(blah)
ClickThisNick
  • 5,110
  • 9
  • 44
  • 69