# Buggy code
def __init__(
    self,
    parent,
    max_entries=100,
    options_button=None,
    text_color=None,
    prevrate_color=None,
):
    QWidget.__init__(self, parent)

    self.setWindowTitle("Pylint")

    self.output = None
    self.error_output = None

    self.text_color = text_color
    self.prevrate_color = prevrate_color

    self.max_entries = max_entries
    self.rdata = []
    if osp.isfile(self.DATAPATH):
        try:
            data = pickle.loads(open(self.DATAPATH, "rb").read())
            if data[0] == self.VERSION:
                self.rdata = data[1:]
        except (EOFError, ImportError):
            pass

    self.filecombo = PythonModulesComboBox(self)

    self.start_button = create_toolbutton(
        self,
        icon=ima.icon("run"),
        text=_("Analyze"),
        tip=_("Run analysis"),
        triggered=self.start,
        text_beside_icon=True,
    )
    self.stop_button = create_toolbutton(
        self,
        icon=ima.icon("stop"),
        text=_("Stop"),
        tip=_("Stop current analysis"),
        text_beside_icon=True,
    )
    self.filecombo.valid.connect(self.start_button.setEnabled)
    self.filecombo.valid.connect(self.show_data)

    browse_button = create_toolbutton(
        self,
        icon=ima.icon("fileopen"),
        tip=_("Select Python file"),
        triggered=self.select_file,
    )

    self.ratelabel = QLabel()
    self.datelabel = QLabel()
    self.log_button = create_toolbutton(
        self,
        icon=ima.icon("log"),
        text=_("Output"),
        text_beside_icon=True,
        tip=_("Complete output"),
        triggered=self.show_log,
    )
    self.treewidget = ResultsTree(self)

    hlayout1 = QHBoxLayout()
    hlayout1.addWidget(self.filecombo)
    hlayout1.addWidget(browse_button)
    hlayout1.addWidget(self.start_button)
    hlayout1.addWidget(self.stop_button)
    if options_button:
        hlayout1.addWidget(options_button)

    hlayout2 = QHBoxLayout()
    hlayout2.addWidget(self.ratelabel)
    hlayout2.addStretch()
    hlayout2.addWidget(self.datelabel)
    hlayout2.addStretch()
    hlayout2.addWidget(self.log_button)

    layout = QVBoxLayout()
    layout.addLayout(hlayout1)
    layout.addLayout(hlayout2)
    layout.addWidget(self.treewidget)
    self.setLayout(layout)

    self.process = None
    self.set_running_state(False)
    self.show_data()

    if self.rdata:
        self.remove_obsolete_items()
        self.filecombo.addItems(self.get_filenames())
    else:
        self.start_button.setEnabled(False)


# Traceback (KeyError)
Traceback (most recent call last):
File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/leo/.local/lib/python3.6/site-packages/pylint/__main__.py", line 7, in <module>
pylint.run_pylint()
File "/home/leo/.local/lib/python3.6/site-packages/pylint/__init__.py", line 19, in run_pylint
Run(sys.argv[1:])
File "/home/leo/.local/lib/python3.6/site-packages/pylint/lint.py", line 1394, in __init__
linter.check(args)
File "/home/leo/.local/lib/python3.6/site-packages/pylint/lint.py", line 801, in check
self._do_check(files_or_modules)
File "/home/leo/.local/lib/python3.6/site-packages/pylint/lint.py", line 920, in _do_check
for descr in self.expand_files(files_or_modules):
File "/home/leo/.local/lib/python3.6/site-packages/pylint/lint.py", line 959, in expand_files
self.add_message(key, args=message)
File "/home/leo/.local/lib/python3.6/site-packages/pylint/utils.py", line 449, in add_message
self.stats['by_module'][self.current_name][msg_cat] += 1
KeyError: None

# Fixed code
def __init__(
    self,
    parent,
    max_entries=100,
    options_button=None,
    text_color=None,
    prevrate_color=None,
):
    QWidget.__init__(self, parent)

    self.setWindowTitle("Pylint")

    self.output = None
    self.error_output = None

    self.text_color = text_color
    self.prevrate_color = prevrate_color

    self.max_entries = max_entries
    self.rdata = []
    if osp.isfile(self.DATAPATH):
        try:
            data = pickle.loads(open(self.DATAPATH, "rb").read())
            if data[0] == self.VERSION:
                self.rdata = data[1:]
        except (EOFError, ImportError):
            pass

    self.filecombo = PythonModulesComboBox(self)

    self.start_button = create_toolbutton(
        self,
        icon=ima.icon("run"),
        text=_("Analyze"),
        tip=_("Run analysis"),
        triggered=self.start,
        text_beside_icon=True,
    )
    self.stop_button = create_toolbutton(
        self,
        icon=ima.icon("stop"),
        text=_("Stop"),
        tip=_("Stop current analysis"),
        text_beside_icon=True,
    )
    self.filecombo.valid.connect(self.start_button.setEnabled)
    self.filecombo.valid.connect(self.show_data)

    browse_button = create_toolbutton(
        self,
        icon=ima.icon("fileopen"),
        tip=_("Select Python file"),
        triggered=self.select_file,
    )

    self.ratelabel = QLabel()
    self.datelabel = QLabel()
    self.log_button = create_toolbutton(
        self,
        icon=ima.icon("log"),
        text=_("Output"),
        text_beside_icon=True,
        tip=_("Complete output"),
        triggered=self.show_log,
    )
    self.treewidget = ResultsTree(self)

    hlayout1 = QHBoxLayout()
    hlayout1.addWidget(self.filecombo)
    hlayout1.addWidget(browse_button)
    hlayout1.addWidget(self.start_button)
    hlayout1.addWidget(self.stop_button)
    if options_button:
        hlayout1.addWidget(options_button)

    hlayout2 = QHBoxLayout()
    hlayout2.addWidget(self.ratelabel)
    hlayout2.addStretch()
    hlayout2.addWidget(self.datelabel)
    hlayout2.addStretch()
    hlayout2.addWidget(self.log_button)

    layout = QVBoxLayout()
    layout.addLayout(hlayout1)
    layout.addLayout(hlayout2)
    layout.addWidget(self.treewidget)
    self.setLayout(layout)

    self.process = None
    self.set_running_state(False)
    self.show_data()

    if self.rdata:
        self.remove_obsolete_items()
        self.filecombo.addItems(self.get_filenames())
        self.start_button.setEnabled(self.filecombo.is_valid())
    else:
        self.start_button.setEnabled(False)