Skip to content

Commit ecbaf8b

Browse files
committed
temp
1 parent 324555b commit ecbaf8b

6 files changed

Lines changed: 10 additions & 18 deletions

File tree

examples/sushi/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
default_gateway="duckdb",
4242
model_defaults=model_defaults,
4343
linter=LinterConfig(
44-
enabled=False,
44+
enabled=True,
4545
rules=[
4646
"ambiguousorinvalidcolumn",
4747
"invalidselectstarexpansion",

sqlmesh/lsp/main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ def _diagnostic_to_lsp_diagnostic(
317317

318318
# Get rule definition location for diagnostics link
319319
rule_location = diagnostic.rule.get_definition_location()
320-
rule_uri = f"file://{rule_location.file_path}#L{rule_location.start_line}"
320+
rule_uri_wihout_extension = URI.from_path(rule_location.file_path)
321+
rule_uri = f"{rule_uri_wihout_extension.value}#L{rule_location.start_line}"
321322

322323
# Use URI format to create a link for "related information"
323324
return types.Diagnostic(
@@ -346,11 +347,9 @@ def _diagnostics_to_lsp_diagnostics(
346347
return lsp_diagnostics
347348

348349
@staticmethod
349-
def _uri_to_path(uri: str) -> str:
350+
def _uri_to_path(uri: str) -> Path:
350351
"""Convert a URI to a path."""
351-
if uri.startswith("file://"):
352-
return Path(uri[7:]).resolve().as_posix()
353-
return Path(uri).resolve().as_posix()
352+
return URI(uri).to_path()
354353

355354
def start(self) -> None:
356355
"""Start the server with I/O transport."""

sqlmesh/lsp/reference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def get_model_definitions_for_a_path(
162162
# Check whether the path exists
163163
if not referenced_model_path.is_file():
164164
continue
165-
referenced_model_uri = f"file://{referenced_model_path}"
165+
referenced_model_uri = URI.from_path(referenced_model_path)
166166

167167
# Extract metadata for positioning
168168
table_meta = TokenPositionDetails.from_meta(table.this.meta)
@@ -179,7 +179,7 @@ def get_model_definitions_for_a_path(
179179

180180
references.append(
181181
Reference(
182-
uri=referenced_model_uri,
182+
uri=referenced_model_uri.value,
183183
range=Range(start=start_pos, end=end_pos),
184184
description=referenced_model.description,
185185
)

sqlmesh/lsp/uri.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ def __eq__(self, other: object) -> bool:
1818
if not isinstance(other, URI):
1919
return False
2020
# Normalize paths for comparison to handle Windows paths
21-
return (
22-
Path(self.value.removeprefix("file://")).as_posix()
23-
== Path(other.value.removeprefix("file://")).as_posix()
24-
)
21+
return self.to_path() == other.to_path()
2522

2623
def __repr__(self) -> str:
2724
return f"URI({self.value})"

tests/lsp/test_completions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ def test_get_sql_completions_with_context_and_file_uri():
3737
lsp_context = LSPContext(context)
3838

3939
file_uri = next(
40-
key
41-
for key in lsp_context.map.keys()
42-
if str(key.to_path()).endswith("models/active_customers.sql")
40+
key for key in lsp_context.map.keys() if str(key.to_path()).endswith("active_customers.sql")
4341
)
4442
completions = get_sql_completions(lsp_context, file_uri)
4543
assert len(completions.keywords) > len(TOKENIZER_KEYWORDS)

tests/lsp/test_context.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ def test_lsp_context():
1414

1515
# find one model in the map
1616
active_customers_key = next(
17-
key
18-
for key in lsp_context.map.keys()
19-
if str(key.to_path()).endswith("models/active_customers.sql")
17+
key for key in lsp_context.map.keys() if str(key.to_path()).endswith("active_customers.sql")
2018
)
2119

2220
# Check that the value is a ModelInfo with the expected model name

0 commit comments

Comments
 (0)