@classmethod<EOL><INDENT>def lint(cls, document, is_saved, flags='<STR_LIT>'):<DEDENT>
if not is_saved:<EOL><INDENT>return cls.last_diags[document.path]<EOL><DEDENT>path = document.path<EOL>if sys.platform.startswith('<STR_LIT>'):<EOL><INDENT>path = path.replace('<STR_LIT:\\>', '<STR_LIT:/>')<EOL><DEDENT>out, _err = py_run(<EOL>'<STR_LIT>'.format(path, flags), return_std=True<EOL>)<EOL>json_str = out.getvalue()<EOL>if not json_str.strip():<EOL><INDENT>cls.last_diags[document.path] = []<EOL>return []<EOL><DEDENT>diagnostics = []<EOL>for diag in json.loads(json_str):<EOL><INDENT>line = diag['<STR_LIT>'] - <NUM_LIT:1><EOL>col = diag['<STR_LIT>']<EOL>end_col = len(document.lines[line]) if document.lines else <NUM_LIT:0><EOL>err_range = {<EOL>'<STR_LIT:start>': {<EOL>'<STR_LIT>': line,<EOL>'<STR_LIT>': col,<EOL>},<EOL>'<STR_LIT:end>': {<EOL>'<STR_LIT>': line,<EOL>'<STR_LIT>': end_col,<EOL>},<EOL>}<EOL>if diag['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>severity = lsp.DiagnosticSeverity.Information<EOL><DEDENT>elif diag['<STR_LIT:type>'] == '<STR_LIT:error>':<EOL><INDENT>severity = lsp.DiagnosticSeverity.Error<EOL><DEDENT>elif diag['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>severity = lsp.DiagnosticSeverity.Error<EOL><DEDENT>elif diag['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>severity = lsp.DiagnosticSeverity.Hint<EOL><DEDENT>elif diag['<STR_LIT:type>'] == '<STR_LIT>':<EOL><INDENT>severity = lsp.DiagnosticSeverity.Warning<EOL><DEDENT>diagnostics.append({<EOL>'<STR_LIT:source>': '<STR_LIT>',<EOL>'<STR_LIT>': err_range,<EOL>'<STR_LIT:message>': '<STR_LIT>'.format(diag['<STR_LIT>'], diag['<STR_LIT:message>']),<EOL>'<STR_LIT>': severity,<EOL>'<STR_LIT:code>': diag['<STR_LIT>']<EOL>})<EOL><DEDENT>cls.last_diags[document.path] = diagnostics<EOL>return diagnostics<EOL>
Plugin interface to pyls linter.

        Args:
            document: The document to be linted.
            is_saved: Whether or not the file has been saved to disk.
            flags: Additional flags to pass to pylint. Not exposed to
                pyls_lint, but used for testing.

        Returns:
            A list of dicts with the following format:

                {
                    'source': 'pylint',
                    'range': {
                        'start': {
                            'line': start_line,
                            'character': start_column,
                        },
                        'end': {
                            'line': end_line,
                            'character': end_column,
                        },
                    }
                    'message': msg,
                    'severity': lsp.DiagnosticSeverity.*,
                }