code: def __updateRequest(self, rect, dy):
          
          if dy:
              self.scroll(0, dy)
          elif self._countCache[0] != self._qpart.blockCount() or \
               self._countCache[1] != self._qpart.textCursor().block().lineCount():
  
              # if block height not added to rect, last line number sometimes is not drawn
              blockHeight = self._qpart.blockBoundingRect(self._qpart.firstVisibleBlock()).height()
  
              self.update(0, rect.y(), self.width(), rect.height() + blockHeight)
              self._countCache = (self._qpart.blockCount(), self._qpart.textCursor().block().lineCount())
  
          if rect.contains(self._qpart.viewport().rect()):
              self._qpart.updateViewportMargins()
docs: Repaint line number area if necessary