Skip to content

Commit bf84dd9

Browse files
committed
feat(lsp): no missing external will create file
- before the fix would only apply if there was a file already there - now it also has the quick fix if the external models file is not present
1 parent 66dfd29 commit bf84dd9

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

sqlmesh/core/linter/rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Fix:
6262
"""A fix that can be applied to resolve a rule violation."""
6363

6464
title: str
65-
edits: t.List[TextEdit]
65+
edits: t.List[TextEdit] = field(default_factory=list)
6666
create_files: t.List[CreateFile] = field(default_factory=list)
6767

6868

sqlmesh/lsp/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ def get_code_actions(
278278
t.Union[
279279
types.TextDocumentEdit,
280280
types.CreateFile,
281+
types.RenameFile,
282+
types.DeleteFile,
281283
]
282284
] = []
283285

tests/core/linter/test_builtin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_no_missing_external_models(tmp_path, copy_to_temp_path) -> None:
5757
assert len(fix.create_files) == 1
5858
create = fix.create_files[0]
5959
assert create.path == sushi_path / "external_models.yaml"
60-
assert create.text == "- name: '\"memory\".\"raw\".\"demographics\"'\n"
60+
assert create.text == '- name: \'"memory"."raw"."demographics"\'\n'
6161

6262

6363
def test_no_missing_external_models_with_existing_file_ending_in_newline(

tests/lsp/test_code_actions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ def test_code_actions_create_file(copy_to_temp_path: t.Callable) -> None:
166166

167167
params = types.CodeActionParams(
168168
text_document=types.TextDocumentIdentifier(uri=uri.value),
169-
range=types.Range(start=types.Position(line=0, character=0), end=types.Position(line=1, character=0)),
169+
range=types.Range(
170+
start=types.Position(line=0, character=0), end=types.Position(line=1, character=0)
171+
),
170172
context=types.CodeActionContext(diagnostics=diagnostics),
171173
)
172174

0 commit comments

Comments
 (0)