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

pyta-uoft / pyta / 22805948042

07 Mar 2026 07:45PM UTC coverage: 89.35% (-0.6%) from 89.956%
22805948042

Pull #1314

github

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

0 of 26 new or added lines in 1 file covered. (0.0%)

3448 of 3859 relevant lines covered (89.35%)

17.32 hits per line

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

0.0
/packages/python-ta/src/python_ta/reporters/LSPReporter.py
NEW
1
import json
×
NEW
2
from pathlib import Path
×
3

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

NEW
8
from .core import NewMessage, PythonTaReporter
×
9

NEW
10
category_to_lsp = {
×
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

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

23

NEW
24
class LSPReporter(PythonTaReporter):
×
25

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

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

NEW
34
        for filename, msgs in self.gather_messages().items():
×
NEW
35
            diagnostics_list = []
×
NEW
36
            for msg in msgs:
×
NEW
37
                diag = types.Diagnostic(
×
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
                )
NEW
49
                diagnostics_list.append(diag)
×
50

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

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

61

NEW
62
def register(linter: PyLinter):
×
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