@@ -115,9 +115,7 @@ def _create_lsp_context(self, paths: t.List[Path]) -> t.Optional[LSPContext]:
115115 return None
116116
117117 # All the custom LSP methods are registered here and prefixed with _custom
118- def _custom_all_models (
119- self , ls : LanguageServer , params : AllModelsRequest
120- ) -> AllModelsResponse :
118+ def _custom_all_models (self , ls : LanguageServer , params : AllModelsRequest ) -> AllModelsResponse :
121119 uri = URI (params .textDocument .uri )
122120 # Get the document content
123121 content = None
@@ -149,9 +147,7 @@ def _custom_all_models_for_render(
149147 self ._ensure_context_in_folder (current_path )
150148 if self .lsp_context is None :
151149 raise RuntimeError ("No context found" )
152- return AllModelsForRenderResponse (
153- models = self .lsp_context .list_of_models_for_rendering ()
154- )
150+ return AllModelsForRenderResponse (models = self .lsp_context .list_of_models_for_rendering ())
155151
156152 def _custom_format_project (
157153 self , ls : LanguageServer , params : FormatProjectRequest
@@ -173,9 +169,7 @@ def _custom_format_project(
173169
174170 def _custom_api (
175171 self , ls : LanguageServer , request : ApiRequest
176- ) -> t .Union [
177- ApiResponseGetModels , ApiResponseGetColumnLineage , ApiResponseGetLineage
178- ]:
172+ ) -> t .Union [ApiResponseGetModels , ApiResponseGetColumnLineage , ApiResponseGetLineage ]:
179173 ls .log_trace (f"API request: { request } " )
180174 if self .lsp_context is None :
181175 current_path = Path .cwd ()
@@ -197,9 +191,7 @@ def _custom_api(
197191 # /api/lineage/{model}
198192 model_name = urllib .parse .unquote (path_parts [2 ])
199193 lineage = model_lineage (model_name , self .lsp_context .context )
200- non_set_lineage = {
201- k : v for k , v in lineage .items () if v is not None
202- }
194+ non_set_lineage = {k : v for k , v in lineage .items () if v is not None }
203195 return ApiResponseGetLineage (data = non_set_lineage )
204196
205197 if len (path_parts ) == 4 :
@@ -208,9 +200,7 @@ def _custom_api(
208200 column = urllib .parse .unquote (path_parts [3 ])
209201 models_only = False
210202 if hasattr (request , "params" ):
211- models_only = bool (
212- getattr (request .params , "models_only" , False )
213- )
203+ models_only = bool (getattr (request .params , "models_only" , False ))
214204 column_lineage_response = column_lineage (
215205 model_name , column , models_only , self .lsp_context .context
216206 )
@@ -236,9 +226,7 @@ def _register_features(self) -> None:
236226 for name , method in self ._supported_custom_methods .items ():
237227
238228 def create_function_call (method_func : t .Callable ) -> t .Callable :
239- def function_call (
240- ls : LanguageServer , params : t .Any
241- ) -> t .Dict [str , t .Any ]:
229+ def function_call (ls : LanguageServer , params : t .Any ) -> t .Dict [str , t .Any ]:
242230 try :
243231 response = method_func (ls , params )
244232 except Exception as e :
@@ -255,9 +243,7 @@ def initialize(ls: LanguageServer, params: types.InitializeParams) -> None:
255243 try :
256244 # Check if the client supports pull diagnostics
257245 if params .capabilities and params .capabilities .text_document :
258- diagnostics = getattr (
259- params .capabilities .text_document , "diagnostic" , None
260- )
246+ diagnostics = getattr (params .capabilities .text_document , "diagnostic" , None )
261247 if diagnostics :
262248 self .client_supports_pull_diagnostics = True
263249 ls .log_trace ("Client supports pull diagnostics" )
@@ -270,8 +256,7 @@ def initialize(ls: LanguageServer, params: types.InitializeParams) -> None:
270256 if params .workspace_folders :
271257 # Store all workspace folders for later use
272258 self .workspace_folders = [
273- Path (self ._uri_to_path (folder .uri ))
274- for folder in params .workspace_folders
259+ Path (self ._uri_to_path (folder .uri )) for folder in params .workspace_folders
275260 ]
276261
277262 # Try to find a SQLMesh config file in any workspace folder (only at the root level)
@@ -289,9 +274,7 @@ def initialize(ls: LanguageServer, params: types.InitializeParams) -> None:
289274 )
290275
291276 @self .server .feature (types .TEXT_DOCUMENT_DID_OPEN )
292- def did_open (
293- ls : LanguageServer , params : types .DidOpenTextDocumentParams
294- ) -> None :
277+ def did_open (ls : LanguageServer , params : types .DidOpenTextDocumentParams ) -> None :
295278 uri = URI (params .text_document .uri )
296279 context = self ._context_get_or_load (uri )
297280 models = context .map [uri .to_path ()]
@@ -309,9 +292,7 @@ def did_open(
309292 )
310293
311294 @self .server .feature (types .TEXT_DOCUMENT_DID_CHANGE )
312- def did_change (
313- ls : LanguageServer , params : types .DidChangeTextDocumentParams
314- ) -> None :
295+ def did_change (ls : LanguageServer , params : types .DidChangeTextDocumentParams ) -> None :
315296 uri = URI (params .text_document .uri )
316297 context = self ._context_get_or_load (uri )
317298 models = context .map [uri .to_path ()]
@@ -329,9 +310,7 @@ def did_change(
329310 )
330311
331312 @self .server .feature (types .TEXT_DOCUMENT_DID_SAVE )
332- def did_save (
333- ls : LanguageServer , params : types .DidSaveTextDocumentParams
334- ) -> None :
313+ def did_save (ls : LanguageServer , params : types .DidSaveTextDocumentParams ) -> None :
335314 uri = URI (params .text_document .uri )
336315
337316 # Reload the entire context and create a new LSPContext
@@ -365,9 +344,7 @@ def formatting(
365344 document = ls .workspace .get_text_document (params .text_document .uri )
366345 before = document .source
367346 if self .lsp_context is None :
368- raise RuntimeError (
369- f"No context found for document: { document .path } "
370- )
347+ raise RuntimeError (f"No context found for document: { document .path } " )
371348
372349 target = next (
373350 (
@@ -394,9 +371,7 @@ def formatting(
394371 start = types .Position (line = 0 , character = 0 ),
395372 end = types .Position (
396373 line = len (document .lines ),
397- character = len (document .lines [- 1 ])
398- if document .lines
399- else 0 ,
374+ character = len (document .lines [- 1 ]) if document .lines else 0 ,
400375 ),
401376 ),
402377 new_text = after ,
@@ -407,27 +382,20 @@ def formatting(
407382 return []
408383
409384 @self .server .feature (types .TEXT_DOCUMENT_HOVER )
410- def hover (
411- ls : LanguageServer , params : types .HoverParams
412- ) -> t .Optional [types .Hover ]:
385+ def hover (ls : LanguageServer , params : types .HoverParams ) -> t .Optional [types .Hover ]:
413386 """Provide hover information for an object."""
414387 try :
415388 uri = URI (params .text_document .uri )
416389 self ._ensure_context_for_document (uri )
417390 document = ls .workspace .get_text_document (params .text_document .uri )
418391 if self .lsp_context is None :
419- raise RuntimeError (
420- f"No context found for document: { document .path } "
421- )
392+ raise RuntimeError (f"No context found for document: { document .path } " )
422393
423394 references = get_references (self .lsp_context , uri , params .position )
424395 if not references :
425396 return None
426397 reference = references [0 ]
427- if (
428- isinstance (reference , LSPCteReference )
429- or not reference .markdown_description
430- ):
398+ if isinstance (reference , LSPCteReference ) or not reference .markdown_description :
431399 return None
432400 return types .Hover (
433401 contents = types .MarkupContent (
@@ -472,9 +440,7 @@ def goto_definition(
472440 self ._ensure_context_for_document (uri )
473441 document = ls .workspace .get_text_document (params .text_document .uri )
474442 if self .lsp_context is None :
475- raise RuntimeError (
476- f"No context found for document: { document .path } "
477- )
443+ raise RuntimeError (f"No context found for document: { document .path } " )
478444
479445 references = get_references (self .lsp_context , uri , params .position )
480446 location_links = []
@@ -518,9 +484,7 @@ def goto_definition(
518484 )
519485 return location_links
520486 except Exception as e :
521- ls .show_message (
522- f"Error getting references: { e } " , types .MessageType .Error
523- )
487+ ls .show_message (f"Error getting references: { e } " , types .MessageType .Error )
524488 return []
525489
526490 @self .server .feature (types .TEXT_DOCUMENT_REFERENCES )
@@ -533,25 +497,16 @@ def find_references(
533497 self ._ensure_context_for_document (uri )
534498 document = ls .workspace .get_text_document (params .text_document .uri )
535499 if self .lsp_context is None :
536- raise RuntimeError (
537- f"No context found for document: { document .path } "
538- )
500+ raise RuntimeError (f"No context found for document: { document .path } " )
539501
540- all_references = get_all_references (
541- self .lsp_context , uri , params .position
542- )
502+ all_references = get_all_references (self .lsp_context , uri , params .position )
543503
544504 # Convert references to Location objects
545- locations = [
546- types .Location (uri = ref .uri , range = ref .range )
547- for ref in all_references
548- ]
505+ locations = [types .Location (uri = ref .uri , range = ref .range ) for ref in all_references ]
549506
550507 return locations if locations else None
551508 except Exception as e :
552- ls .show_message (
553- f"Error getting locations: { e } " , types .MessageType .Error
554- )
509+ ls .show_message (f"Error getting locations: { e } " , types .MessageType .Error )
555510 return None
556511
557512 @self .server .feature (types .TEXT_DOCUMENT_DIAGNOSTIC )
@@ -564,10 +519,7 @@ def diagnostic(
564519 diagnostics , result_id = self ._get_diagnostics_for_uri (uri )
565520
566521 # Check if client provided a previous result ID
567- if (
568- hasattr (params , "previous_result_id" )
569- and params .previous_result_id == result_id
570- ):
522+ if hasattr (params , "previous_result_id" ) and params .previous_result_id == result_id :
571523 # Return unchanged report if diagnostics haven't changed
572524 return types .RelatedUnchangedDocumentDiagnosticReport (
573525 kind = types .DocumentDiagnosticReportKind .Unchanged ,
@@ -616,10 +568,7 @@ def workspace_diagnostic(
616568
617569 # Check if we have a previous result ID for this file
618570 previous_result_id = None
619- if (
620- hasattr (params , "previous_result_ids" )
621- and params .previous_result_ids
622- ):
571+ if hasattr (params , "previous_result_ids" ) and params .previous_result_ids :
623572 for prev in params .previous_result_ids :
624573 if prev .uri == uri .value :
625574 previous_result_id = prev .value
@@ -655,9 +604,7 @@ def workspace_diagnostic(
655604
656605 @self .server .feature (
657606 types .TEXT_DOCUMENT_COMPLETION ,
658- types .CompletionOptions (
659- trigger_characters = ["@" ]
660- ), # advertise "@" for macros
607+ types .CompletionOptions (trigger_characters = ["@" ]), # advertise "@" for macros
661608 )
662609 def completion (
663610 ls : LanguageServer , params : types .CompletionParams
@@ -729,9 +676,7 @@ def completion(
729676 get_sql_completions (None , URI (params .text_document .uri ))
730677 return None
731678
732- def _get_diagnostics_for_uri (
733- self , uri : URI
734- ) -> t .Tuple [t .List [types .Diagnostic ], int ]:
679+ def _get_diagnostics_for_uri (self , uri : URI ) -> t .Tuple [t .List [types .Diagnostic ], int ]:
735680 """Get diagnostics for a specific URI, returning (diagnostics, result_id).
736681
737682 Since we no longer track version numbers, we always return 0 as the result_id.
@@ -866,9 +811,7 @@ def _diagnostics_to_lsp_diagnostics(
866811 """
867812 lsp_diagnostics = {}
868813 for diagnostic in diagnostics :
869- lsp_diagnostic = SQLMeshLanguageServer ._diagnostic_to_lsp_diagnostic (
870- diagnostic
871- )
814+ lsp_diagnostic = SQLMeshLanguageServer ._diagnostic_to_lsp_diagnostic (diagnostic )
872815 if lsp_diagnostic is not None :
873816 # Create a unique key combining message and range
874817 diagnostic_key = (
0 commit comments