Wrong unused import

Hello,

consider this code:

from AutomaticHacker import constants


if constants.QT5:
    from PyQt5.QtCore import QAbstractTableModel, pyqtSignal, QModelIndex, Qt, QAbstractItemModel, QSize
    from PyQt5.QtGui import QColor, QFont
else:
    from PyQt4.QtCore import QAbstractTableModel, pyqtSignal, QModelIndex, Qt, QAbstractItemModel, QSize
    from PyQt4.QtGui import QColor, QFont


Pycharm marks the whole line

from PyQt5.QtCore import QAbstractTableModel, pyqtSignal, QModelIndex, Qt, QAbstractItemModel, QSize

as an unused import, although only QSize ist not used. I know, I could fix this by hand by removing QSize from the import list. However, it would break my code if I would optimize imports automatically. Any way to fix this?

Please sign in to leave a comment.