• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pyta-uoft / pyta / 22815847249

08 Mar 2026 06:44AM UTC coverage: 90.003% (+0.05%) from 89.956%
22815847249

Pull #1314

github

web-flow
Merge c7e0f4d87 into 8865e1800
Pull Request #1314: Creation of LSPReporter

27 of 28 new or added lines in 2 files covered. (96.43%)

3475 of 3861 relevant lines covered (90.0%)

17.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/packages/python-ta/src/python_ta/reporters/lsp_reporter.py
1
import json
20✔
2
from pathlib import Path
20✔
3

4
from lsprotocol import converters, types
20✔
5
from pylint.lint import PyLinter
20✔
6
from pylint.reporters.ureports.nodes import BaseLayout
20✔
7

8
from .core import NewMessage, PythonTaReporter
20✔
9

10
category_to_lsp = {
20✔
11
    "error": types.DiagnosticSeverity.Error,
12
    "fatal": types.DiagnosticSeverity.Error,
13
    "warning": types.DiagnosticSeverity.Warning,
14
    "convention": types.DiagnosticSeverity.Information,
15
    "refactor": types.DiagnosticSeverity.Hint,
16
}
17

18

19
def _lsp_severity(category: str) -> types.DiagnosticSeverity:
20✔
20
    """Convert the PyLint category to DiagnosticSeverity type, return default of warning"""
21
    return category_to_lsp.get(category, types.DiagnosticSeverity.Warning)
20✔
22

23

24
class LSPReporter(PythonTaReporter):
20✔
25

26
    name = "pyta-lsp"
20✔
27
    OUTPUT_FILENAME = "pyta_lsp_report.json"
20✔
28
    messages: dict[str, list[NewMessage]]
16✔
29

30
    def display_messages(self, layout: BaseLayout) -> None:
20✔
31
        output = []
20✔
32
        converter = converters.get_converter()
20✔
33

34
        for filename, msgs in self.gather_messages().items():
20✔
35
            diagnostics_list = []
20✔
36
            for msg in msgs:
20✔
37
                diag = types.Diagnostic(
20✔
38
                    range=types.Range(
39
                        start=types.Position(line=msg.line - 1, character=msg.column or 0),
40
                        end=types.Position(
41
                            line=(msg.end_line or msg.line) - 1, character=msg.end_column or 0
42
                        ),
43
                    ),
44
                    message=msg.msg,
45
                    severity=_lsp_severity(msg.category),
46
                    code=msg.msg_id,
47
                    source="python-ta",
48
                )
49
                diagnostics_list.append(diag)
20✔
50

51
            params = types.PublishDiagnosticsParams(
20✔
52
                uri=Path(filename).as_uri(), diagnostics=diagnostics_list
53
            )
54
            output.append(
20✔
55
                converter.unstructure(params, unstructure_as=types.PublishDiagnosticsParams)
56
            )
57

58
        self.writeln(json.dumps(output, indent=4))
20✔
59
        self.out.flush()
20✔
60

61

62
def register(linter: PyLinter):
20✔
NEW
63
    linter.register_reporter(LSPReporter)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc