Skip to content

Commit e1adaea

Browse files
committed
🧹 add diagnostic type
1 parent 762853c commit e1adaea

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

pylsp/lsp.py

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Copyright 2017-2020 Palantir Technologies, Inc.
22
# Copyright 2021- Python Language Server Contributors.
33

4-
"""Some Language Server Protocol constants
4+
"""Some Language Server Protocol constants.
55
66
https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md
77
"""
88

9+
from enum import Enum
10+
from typing import Optional, TypedDict
11+
912

1013
class CompletionItemKind:
1114
Text = 1
@@ -41,14 +44,14 @@ class DocumentHighlightKind:
4144
Write = 3
4245

4346

44-
class DiagnosticSeverity:
47+
class DiagnosticSeverity(int, Enum):
4548
Error = 1
4649
Warning = 2
4750
Information = 3
4851
Hint = 4
4952

5053

51-
class DiagnosticTag:
54+
class DiagnosticTag(int, Enum):
5255
Unnecessary = 1
5356
Deprecated = 2
5457

@@ -113,3 +116,31 @@ class ErrorCodes:
113116
ContentModified = -32801
114117
RequestCancelled = -32800
115118
lspReservedErrorRangeEnd = -32800
119+
120+
121+
class Position(TypedDict):
122+
"""Position in a text document expressed as zero-based line and character offset.
123+
124+
A position is between two characters like an 'insert' cursor in a editor.
125+
Special values like for example (-1,-1) which indicates that the position
126+
is invalid.
127+
"""
128+
129+
line: int
130+
character: int
131+
132+
class Range(TypedDict):
133+
"""The range type represents a span of text in the document."""
134+
135+
start: Position
136+
end: Position
137+
138+
class Diagnostic(TypedDict):
139+
"""The type of a diagnostic the lsp should publish."""
140+
141+
source: str
142+
range: Range
143+
message: str
144+
severity: DiagnosticSeverity
145+
code: str
146+
tags: list[DiagnosticTag]

0 commit comments

Comments
 (0)