# 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(0)
    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()

    painter.translate(textRect.topLeft())
    painter.setClipRect(textRect.translated(-textRect.topLeft()))
    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(0)
    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()

    painter.translate(textRect.topLeft())
    painter.setClipRect(textRect.translated(-textRect.topLeft()))
    doc.documentLayout().draw(painter, ctx)
    painter.restore()