# Buggy code
def paint(self, painter, option, index):
    options = QStyleOptionViewItem(option)
    self.initStyleOption(options, index)

    style = QApplication.style() if options.widget is None else options.widget.style()

    doc = QTextDocument()
    doc.setDocumentMargin(self._margin)
    doc.setHtml(options.text)

    options.text = ""
    style.drawControl(QStyle.CE_ItemViewItem, options, painter)

    ctx = QAbstractTextDocumentLayout.PaintContext()

    textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
    painter.save()

    # Adjustments for the file switcher
    if hasattr(options.widget, "files_list"):
        if style.objectName() in ["oxygen", "qtcurve", "breeze"]:
            if options.widget.files_list:
                painter.translate(textRect.topLeft() + QPoint(4, -9))
            else:
                painter.translate(textRect.topLeft())
        else:
            if options.widget.files_list:
                painter.translate(textRect.topLeft() + QPoint(4, 4))
            else:
                painter.translate(textRect.topLeft() + QPoint(2, 4))
    else:
        painter.translate(textRect.topLeft() + QPoint(0, -3))
    doc.documentLayout().draw(painter, ctx)
    painter.restore()


# Traceback (TypeError)
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/spyder/widgets/helperwidgets.py", line 127, in paint
textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
TypeError: subElementRect(self, QStyle.SubElement, QStyleOption, QWidget): not enough arguments
WARNING:spyder.widgets.github.backend:failed to send bug report on github. response={'code': 404, 'json': {'message': 'Not Found', 'documentation_url': 'https://developer.github.com/v3/issues/#create-an-issue'}}

# Fixed code
def paint(self, painter, option, index):
    options = QStyleOptionViewItem(option)
    self.initStyleOption(options, index)

    style = QApplication.style() if options.widget is None else options.widget.style()

    doc = QTextDocument()
    doc.setDocumentMargin(self._margin)
    doc.setHtml(options.text)

    options.text = ""
    style.drawControl(QStyle.CE_ItemViewItem, options, painter)

    ctx = QAbstractTextDocumentLayout.PaintContext()

    textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options, None)
    painter.save()

    # Adjustments for the file switcher
    if hasattr(options.widget, "files_list"):
        if style.objectName() in ["oxygen", "qtcurve", "breeze"]:
            if options.widget.files_list:
                painter.translate(textRect.topLeft() + QPoint(4, -9))
            else:
                painter.translate(textRect.topLeft())
        else:
            if options.widget.files_list:
                painter.translate(textRect.topLeft() + QPoint(4, 4))
            else:
                painter.translate(textRect.topLeft() + QPoint(2, 4))
    else:
        painter.translate(textRect.topLeft() + QPoint(0, -3))
    doc.documentLayout().draw(painter, ctx)
    painter.restore()