Skip to content

Commit 0023ffd

Browse files
committed
[FIX] server: adapt code for cattrs==23.2.1
new lib version doesn't allow int as severity parameter, but enum only
1 parent e776f86 commit 0023ffd

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

server/core/module.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@
66
from .python_arch_builder import PythonArchBuilder
77
from ..references import RegisteredRef
88
from .symbol import ConcreteSymbol
9-
from lsprotocol.types import (CompletionItem, CompletionList, CompletionOptions,
10-
CompletionParams, ConfigurationItem,
11-
ConfigurationParams, Diagnostic, DiagnosticTag,
12-
DidChangeTextDocumentParams,
13-
DidCloseTextDocumentParams,
14-
DidOpenTextDocumentParams, MessageType, Position,
15-
Range, Registration, RegistrationParams,
16-
SemanticTokens, SemanticTokensLegend, SemanticTokensParams,
17-
Unregistration, UnregistrationParams)
9+
from lsprotocol.types import (Diagnostic, DiagnosticTag, Position,
10+
Range, DiagnosticSeverity)
1811

1912
class ModuleSymbol(ConcreteSymbol):
2013

@@ -71,7 +64,7 @@ def load_manifest(self, fileInfo):
7164
),
7265
message = "A manifest should only contains one dictionnary",
7366
source = EXTENSION_NAME,
74-
severity= 1,
67+
severity= DiagnosticSeverity.Error,
7568
)]
7669
dic = ast_body[0].value
7770
self.module_name = ""
@@ -116,7 +109,7 @@ def load_manifest(self, fileInfo):
116109
message = "'active' is deprecated and has been replaced by 'auto_install'",
117110
source = EXTENSION_NAME,
118111
tags=[DiagnosticTag.Deprecated],
119-
severity= 1,
112+
severity= DiagnosticSeverity.Error,
120113
))
121114
else:
122115
if key.value not in ["version", "description", "author", "website", "license",
@@ -129,7 +122,7 @@ def load_manifest(self, fileInfo):
129122
self.depends.append("base")
130123
return diags
131124

132-
def _create_diag(self, node, message, severity=1):
125+
def _create_diag(self, node, message, severity=DiagnosticSeverity.Error):
133126
return Diagnostic(
134127
range = Range(
135128
start=Position(line=node.lineno-1, character=node.col_offset+1),

server/core/python_arch_eval.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ..python_utils import PythonUtils
1212
from ..references import *
1313
from .import_resolver import *
14-
from lsprotocol.types import (Diagnostic,MessageType,Position, Range)
14+
from lsprotocol.types import (Diagnostic,MessageType,Position, Range, DiagnosticSeverity)
1515

1616

1717
class PythonArchEval(ast.NodeVisitor):
@@ -106,7 +106,7 @@ def eval_symbols_from_import_stmt(self, from_stmt, name_aliases, level, node):
106106
),
107107
message = ".".join(file_tree + [node_alias.name]) + " not found",
108108
source = EXTENSION_NAME,
109-
severity = 2
109+
severity = DiagnosticSeverity.Warning
110110
))
111111
else:
112112
if (file_tree + node_alias.name.split("."))[0] in BUILT_IN_LIBS:
@@ -122,7 +122,7 @@ def eval_symbols_from_import_stmt(self, from_stmt, name_aliases, level, node):
122122
),
123123
message = ".".join(file_tree + [node_alias.name]) + " not found",
124124
source = EXTENSION_NAME,
125-
severity = 2
125+
severity = DiagnosticSeverity.Warning
126126
))
127127

128128
def visit_Try(self, node):
@@ -180,7 +180,7 @@ def _create_diagnostic_base_not_found(self, symbol, not_found_name, node, full_n
180180
),
181181
message = "Base class " + full_name + " not found",
182182
source = EXTENSION_NAME,
183-
severity= 2,
183+
severity= DiagnosticSeverity.Warning,
184184
)
185185
)
186186

@@ -226,7 +226,7 @@ def load_base_class(self, symbol, node):
226226
),
227227
message = "Base class " + full_base + " is not a class",
228228
source = EXTENSION_NAME,
229-
severity= 2,
229+
severity= DiagnosticSeverity.Warning,
230230
)
231231
)
232232
continue

server/features/validation/python_validator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ...python_utils import PythonUtils
88
from ...core.file_mgr import FileMgr
99
from ...core.import_resolver import resolve_import_stmt
10-
from lsprotocol.types import (Diagnostic,DiagnosticTag,Position, Range)
10+
from lsprotocol.types import (Diagnostic,DiagnosticTag,Position, Range, DiagnosticSeverity)
1111

1212
class ClassContentCacheValidator():
1313

@@ -99,7 +99,7 @@ def _resolve_import(self, from_stmt, name_aliases, level, node):
9999
),
100100
message = module.dir_name + " is not in the dependencies of the module",
101101
source = EXTENSION_NAME,
102-
severity = 2
102+
severity = DiagnosticSeverity.Warning
103103
))
104104

105105
def visit_Assign(self, node):
@@ -286,7 +286,7 @@ def validate_structure(self):
286286
message = symbol.eval.get_symbol().name + " is deprecated: " + symbol.eval.get_symbol().deprecated_reason,
287287
source = EXTENSION_NAME,
288288
tags=[DiagnosticTag.Deprecated],
289-
severity = 3
289+
severity = DiagnosticSeverity.Information
290290
))
291291
if symbol.type == SymType.CLASS:
292292
if symbol.modelData:
@@ -307,7 +307,7 @@ def validate_structure(self):
307307
),
308308
message = inherit + " does not exist",
309309
source = EXTENSION_NAME,
310-
severity = 1
310+
severity = DiagnosticSeverity.Error
311311
))
312312
else:
313313
inherited_models = model.get_main_symbols(self.currentModule)
@@ -320,7 +320,7 @@ def validate_structure(self):
320320
),
321321
message = "This model is ambiguous. Please fix your dependencies or avoid using same model name in different modules",
322322
source = EXTENSION_NAME,
323-
severity = 1
323+
severity = DiagnosticSeverity.Error
324324
))
325325
elif not inherited_models:
326326
model_syms = model.get_main_symbols()
@@ -337,5 +337,5 @@ def validate_structure(self):
337337
),
338338
message = inherit + " is not in your dependencies. Please review the dependencies of your module to add " + models + " in it",
339339
source = EXTENSION_NAME,
340-
severity = 1
340+
severity = DiagnosticSeverity.Error
341341
))

0 commit comments

Comments
 (0)