Skip to content

Commit 1b1d085

Browse files
authored
fix(vscode): fix vscode serializability (#4471)
1 parent 8538ce1 commit 1b1d085

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

sqlmesh/lsp/main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def all_models(ls: LanguageServer, params: AllModelsRequest) -> AllModelsRespons
9292
return get_sql_completions(None, uri)
9393

9494
@self.server.feature(API_FEATURE)
95-
def api(
96-
ls: LanguageServer, request: ApiRequest
97-
) -> t.Union[ApiResponseGetModels, ApiResponseGetLineage, ApiResponseGetColumnLineage]:
95+
def api(ls: LanguageServer, request: ApiRequest) -> t.Dict[str, t.Any]:
9896
ls.log_trace(f"API request: {request}")
9997
if self.lsp_context is None:
10098
raise RuntimeError("No context found")
@@ -105,15 +103,17 @@ def api(
105103
if request.method == "GET":
106104
if path_parts == ["api", "models"]:
107105
# /api/models
108-
return ApiResponseGetModels(data=get_models(self.lsp_context.context))
106+
return ApiResponseGetModels(
107+
data=get_models(self.lsp_context.context)
108+
).model_dump(mode="json")
109109

110110
if path_parts[:2] == ["api", "lineage"]:
111111
if len(path_parts) == 3:
112112
# /api/lineage/{model}
113113
model_name = urllib.parse.unquote(path_parts[2])
114114
lineage = model_lineage(model_name, self.lsp_context.context)
115115
non_set_lineage = {k: v for k, v in lineage.items() if v is not None}
116-
return ApiResponseGetLineage(data=non_set_lineage)
116+
return ApiResponseGetLineage(data=non_set_lineage).model_dump(mode="json")
117117

118118
if len(path_parts) == 4:
119119
# /api/lineage/{model}/{column}
@@ -123,7 +123,9 @@ def api(
123123
column_lineage_response = column_lineage(
124124
model_name, column, False, self.lsp_context.context
125125
)
126-
return ApiResponseGetColumnLineage(data=column_lineage_response)
126+
return ApiResponseGetColumnLineage(data=column_lineage_response).model_dump(
127+
mode="json"
128+
)
127129

128130
raise NotImplementedError(f"API request not implemented: {request.url}")
129131

0 commit comments

Comments
 (0)