from pyqode.core import modes
from pyqode.core.api import TextHelper


class AutoCompleteMode(modes.AutoCompleteMode):
    def __init__(self):
        super(AutoCompleteMode, self).__init__()
        self.QUOTES_FORMATS.pop("'")
        self.SELECTED_QUOTES_FORMATS.pop("'")
        self.MAPPING.pop("'")

    def _on_key_pressed(self, event):
        helper = TextHelper(self.editor)
        indent = helper.line_indent() * ' '
        if self.editor.textCursor().positionInBlock() == len(indent):
            self.QUOTES_FORMATS['"'] = '%s:'
        else:
            self.QUOTES_FORMATS['"'] = '%s'
        self.QUOTES_FORMATS['{'] = '\n' + indent + '%s'
        self.QUOTES_FORMATS['['] = '\n' + indent + '%s'
        super(AutoCompleteMode, self)._on_key_pressed(event)

from pyqode.core import modes
from pyqode.core.api import TextHelper


class AutoCompleteMode(modes.AutoCompleteMode):
    def __init__(self):
        super(AutoCompleteMode, self).__init__()
        try:
            self.QUOTES_FORMATS.pop("'")
            self.SELECTED_QUOTES_FORMATS.pop("'")
            self.MAPPING.pop("'")
        except KeyError:
            pass

    def _on_key_pressed(self, event):
        helper = TextHelper(self.editor)
        indent = helper.line_indent() * ' '
        if self.editor.textCursor().positionInBlock() == len(indent):
            self.QUOTES_FORMATS['"'] = '%s:'
        else:
            self.QUOTES_FORMATS['"'] = '%s'
        self.QUOTES_FORMATS['{'] = '\n' + indent + '%s'
        self.QUOTES_FORMATS['['] = '\n' + indent + '%s'
        super(AutoCompleteMode, self)._on_key_pressed(event)

Fix issue with auto complete when more than 1 editor has been created