Skip to content

Commit 23d149b

Browse files
committed
fixing comments
1 parent a0deb4c commit 23d149b

File tree

11 files changed

+211
-211
lines changed

11 files changed

+211
-211
lines changed

sqlmesh/core/linter/rules/builtin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from sqlmesh.core.linter.rule import Rule, RuleViolation, Range, Fix, TextEdit
1717
from sqlmesh.core.linter.definition import RuleSet
1818
from sqlmesh.core.model import Model, SqlModel, ExternalModel
19-
from sqlmesh.utils.lineage import extract_references_from_query, LSPExternalModelReference
19+
from sqlmesh.utils.lineage import extract_references_from_query, ExternalModelReference
2020

2121

2222
class NoSelectStar(Rule):
@@ -167,10 +167,10 @@ def check_model(
167167
dialect=model.dialect,
168168
): ref
169169
for ref in references
170-
if isinstance(ref, LSPExternalModelReference) and ref.path is None
170+
if isinstance(ref, ExternalModelReference) and ref.path is None
171171
}
172172

173-
# Ensure that depends_on are a subset of the external references. If not, return generic violation.
173+
# Ensure that depends_on and external references match.
174174
if not_registered_external_models != set(external_references.keys()):
175175
return self._standard_error_message(
176176
model_name=model.fqn,

sqlmesh/lsp/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060
from sqlmesh.lsp.helpers import to_lsp_range, to_sqlmesh_position
6161
from sqlmesh.lsp.hints import get_hints
6262
from sqlmesh.lsp.reference import (
63-
LSPCteReference,
64-
LSPModelReference,
63+
CTEReference,
64+
ModelReference,
6565
get_references,
6666
get_all_references,
6767
)
6868
from sqlmesh.lsp.rename import prepare_rename, rename_symbol, get_document_highlights
6969
from sqlmesh.lsp.uri import URI
7070
from sqlmesh.utils.errors import ConfigError
71-
from sqlmesh.utils.lineage import LSPExternalModelReference
71+
from sqlmesh.utils.lineage import ExternalModelReference
7272
from web.server.api.endpoints.lineage import column_lineage, model_lineage
7373
from web.server.api.endpoints.models import get_models
7474
from typing import Union
@@ -479,7 +479,7 @@ def hover(ls: LanguageServer, params: types.HoverParams) -> t.Optional[types.Hov
479479
if not references:
480480
return None
481481
reference = references[0]
482-
if isinstance(reference, LSPCteReference) or not reference.markdown_description:
482+
if isinstance(reference, CTEReference) or not reference.markdown_description:
483483
return None
484484
return types.Hover(
485485
contents=types.MarkupContent(
@@ -525,7 +525,7 @@ def goto_definition(
525525
location_links = []
526526
for reference in references:
527527
# Use target_range if available (CTEs, Macros, and external models in YAML)
528-
if isinstance(reference, LSPModelReference):
528+
if isinstance(reference, ModelReference):
529529
# Regular SQL models - default to start of file
530530
target_range = types.Range(
531531
start=types.Position(line=0, character=0),
@@ -535,7 +535,7 @@ def goto_definition(
535535
start=types.Position(line=0, character=0),
536536
end=types.Position(line=0, character=0),
537537
)
538-
elif isinstance(reference, LSPExternalModelReference):
538+
elif isinstance(reference, ExternalModelReference):
539539
# External models may have target_range set for YAML files
540540
target_range = types.Range(
541541
start=types.Position(line=0, character=0),

sqlmesh/lsp/reference.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
from sqlmesh.lsp.uri import URI
1414
from sqlmesh.utils.lineage import (
15-
LSPMacroReference,
16-
LSPCteReference,
15+
MacroReference,
16+
CTEReference,
1717
Reference,
18-
LSPModelReference,
18+
ModelReference,
1919
extract_references_from_query,
2020
)
2121
import ast
@@ -268,7 +268,7 @@ def get_macro_reference(
268268

269269
# Create a reference to the macro definition
270270

271-
return LSPMacroReference(
271+
return MacroReference(
272272
path=path,
273273
range=macro_range,
274274
target_range=Range(
@@ -301,7 +301,7 @@ def get_built_in_macro_reference(macro_name: str, macro_range: Range) -> t.Optio
301301
# Calculate the end line number by counting the number of source lines
302302
end_line_number = line_number + len(source_lines) - 1
303303

304-
return LSPMacroReference(
304+
return MacroReference(
305305
path=Path(filename),
306306
range=macro_range,
307307
target_range=Range(
@@ -314,7 +314,7 @@ def get_built_in_macro_reference(macro_name: str, macro_range: Range) -> t.Optio
314314

315315
def get_model_find_all_references(
316316
lint_context: LSPContext, document_uri: URI, position: Position
317-
) -> t.List[LSPModelReference]:
317+
) -> t.List[ModelReference]:
318318
"""
319319
Get all references to a model across the entire project.
320320
@@ -332,7 +332,7 @@ def get_model_find_all_references(
332332
# Find the model reference at the cursor position
333333
model_at_position = next(
334334
filter(
335-
lambda ref: isinstance(ref, LSPModelReference)
335+
lambda ref: isinstance(ref, ModelReference)
336336
and _position_within_range(position, ref.range),
337337
get_model_definitions_for_a_path(lint_context, document_uri),
338338
),
@@ -342,13 +342,13 @@ def get_model_find_all_references(
342342
if not model_at_position:
343343
return []
344344

345-
assert isinstance(model_at_position, LSPModelReference) # for mypy
345+
assert isinstance(model_at_position, ModelReference) # for mypy
346346

347347
target_model_path = model_at_position.path
348348

349349
# Start with the model definition
350-
all_references: t.List[LSPModelReference] = [
351-
LSPModelReference(
350+
all_references: t.List[ModelReference] = [
351+
ModelReference(
352352
path=model_at_position.path,
353353
range=Range(
354354
start=Position(line=0, character=0),
@@ -360,15 +360,15 @@ def get_model_find_all_references(
360360

361361
# Then add references from the current file
362362
current_file_refs = filter(
363-
lambda ref: isinstance(ref, LSPModelReference) and ref.path == target_model_path,
363+
lambda ref: isinstance(ref, ModelReference) and ref.path == target_model_path,
364364
get_model_definitions_for_a_path(lint_context, document_uri),
365365
)
366366

367367
for ref in current_file_refs:
368-
assert isinstance(ref, LSPModelReference) # for mypy
368+
assert isinstance(ref, ModelReference) # for mypy
369369

370370
all_references.append(
371-
LSPModelReference(
371+
ModelReference(
372372
path=document_uri.to_path(),
373373
range=ref.range,
374374
markdown_description=ref.markdown_description,
@@ -385,15 +385,15 @@ def get_model_find_all_references(
385385

386386
# Get model references that point to the target model
387387
matching_refs = filter(
388-
lambda ref: isinstance(ref, LSPModelReference) and ref.path == target_model_path,
388+
lambda ref: isinstance(ref, ModelReference) and ref.path == target_model_path,
389389
get_model_definitions_for_a_path(lint_context, file_uri),
390390
)
391391

392392
for ref in matching_refs:
393-
assert isinstance(ref, LSPModelReference) # for mypy
393+
assert isinstance(ref, ModelReference) # for mypy
394394

395395
all_references.append(
396-
LSPModelReference(
396+
ModelReference(
397397
path=path,
398398
range=ref.range,
399399
markdown_description=ref.markdown_description,
@@ -405,7 +405,7 @@ def get_model_find_all_references(
405405

406406
def get_cte_references(
407407
lint_context: LSPContext, document_uri: URI, position: Position
408-
) -> t.List[LSPCteReference]:
408+
) -> t.List[CTEReference]:
409409
"""
410410
Get all references to a CTE at a specific position in a document.
411411
@@ -421,10 +421,10 @@ def get_cte_references(
421421
"""
422422

423423
# Filter to get the CTE references
424-
cte_references: t.List[LSPCteReference] = [
424+
cte_references: t.List[CTEReference] = [
425425
ref
426426
for ref in get_model_definitions_for_a_path(lint_context, document_uri)
427-
if isinstance(ref, LSPCteReference)
427+
if isinstance(ref, CTEReference)
428428
]
429429

430430
if not cte_references:
@@ -446,7 +446,7 @@ def get_cte_references(
446446

447447
# Add the CTE definition
448448
matching_references = [
449-
LSPCteReference(
449+
CTEReference(
450450
path=document_uri.to_path(),
451451
range=target_cte_definition_range,
452452
target_range=target_cte_definition_range,
@@ -457,7 +457,7 @@ def get_cte_references(
457457
for ref in cte_references:
458458
if ref.target_range == target_cte_definition_range:
459459
matching_references.append(
460-
LSPCteReference(
460+
CTEReference(
461461
path=document_uri.to_path(),
462462
range=ref.range,
463463
target_range=ref.target_range,
@@ -469,7 +469,7 @@ def get_cte_references(
469469

470470
def get_macro_find_all_references(
471471
lsp_context: LSPContext, document_uri: URI, position: Position
472-
) -> t.List[LSPMacroReference]:
472+
) -> t.List[MacroReference]:
473473
"""
474474
Get all references to a macro at a specific position in a document.
475475
@@ -486,7 +486,7 @@ def get_macro_find_all_references(
486486
# Find the macro reference at the cursor position
487487
macro_at_position = next(
488488
filter(
489-
lambda ref: isinstance(ref, LSPMacroReference)
489+
lambda ref: isinstance(ref, MacroReference)
490490
and _position_within_range(position, ref.range),
491491
get_macro_definitions_for_a_path(lsp_context, document_uri),
492492
),
@@ -496,14 +496,14 @@ def get_macro_find_all_references(
496496
if not macro_at_position:
497497
return []
498498

499-
assert isinstance(macro_at_position, LSPMacroReference) # for mypy
499+
assert isinstance(macro_at_position, MacroReference) # for mypy
500500

501501
target_macro_path = macro_at_position.path
502502
target_macro_target_range = macro_at_position.target_range
503503

504504
# Start with the macro definition
505-
all_references: t.List[LSPMacroReference] = [
506-
LSPMacroReference(
505+
all_references: t.List[MacroReference] = [
506+
MacroReference(
507507
path=target_macro_path,
508508
range=target_macro_target_range,
509509
target_range=target_macro_target_range,
@@ -517,16 +517,16 @@ def get_macro_find_all_references(
517517

518518
# Get macro references that point to the same macro definition
519519
matching_refs = filter(
520-
lambda ref: isinstance(ref, LSPMacroReference)
520+
lambda ref: isinstance(ref, MacroReference)
521521
and ref.path == target_macro_path
522522
and ref.target_range == target_macro_target_range,
523523
get_macro_definitions_for_a_path(lsp_context, file_uri),
524524
)
525525

526526
for ref in matching_refs:
527-
assert isinstance(ref, LSPMacroReference) # for mypy
527+
assert isinstance(ref, MacroReference) # for mypy
528528
all_references.append(
529-
LSPMacroReference(
529+
MacroReference(
530530
path=path,
531531
range=ref.range,
532532
target_range=ref.target_range,

sqlmesh/lsp/rename.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from sqlmesh.lsp.reference import (
1414
_position_within_range,
1515
get_cte_references,
16-
LSPCteReference,
16+
CTEReference,
1717
)
1818
from sqlmesh.lsp.uri import URI
1919

@@ -82,7 +82,7 @@ def rename_symbol(
8282
return None
8383

8484

85-
def _rename_cte(cte_references: t.List[LSPCteReference], new_name: str) -> WorkspaceEdit:
85+
def _rename_cte(cte_references: t.List[CTEReference], new_name: str) -> WorkspaceEdit:
8686
"""
8787
Create a WorkspaceEdit for renaming a CTE.
8888

0 commit comments

Comments
 (0)