sqlmesh 0.206.2.dev1__py3-none-any.whl → 0.206.2.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlmesh/_version.py +2 -2
- sqlmesh/core/linter/rule.py +11 -2
- sqlmesh/core/linter/rules/builtin.py +19 -2
- sqlmesh/lsp/context.py +35 -4
- {sqlmesh-0.206.2.dev1.dist-info → sqlmesh-0.206.2.dev2.dist-info}/METADATA +1 -1
- {sqlmesh-0.206.2.dev1.dist-info → sqlmesh-0.206.2.dev2.dist-info}/RECORD +10 -10
- {sqlmesh-0.206.2.dev1.dist-info → sqlmesh-0.206.2.dev2.dist-info}/WHEEL +0 -0
- {sqlmesh-0.206.2.dev1.dist-info → sqlmesh-0.206.2.dev2.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.206.2.dev1.dist-info → sqlmesh-0.206.2.dev2.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.206.2.dev1.dist-info → sqlmesh-0.206.2.dev2.dist-info}/top_level.txt +0 -0
sqlmesh/_version.py
CHANGED
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '0.206.2.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 206, 2, '
|
|
20
|
+
__version__ = version = '0.206.2.dev2'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 206, 2, 'dev2')
|
sqlmesh/core/linter/rule.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
|
-
from dataclasses import dataclass
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
7
|
from sqlmesh.core.model import Model
|
|
@@ -49,12 +49,21 @@ class TextEdit:
|
|
|
49
49
|
new_text: str
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
@dataclass(frozen=True)
|
|
53
|
+
class CreateFile:
|
|
54
|
+
"""Create a new file with the provided text."""
|
|
55
|
+
|
|
56
|
+
path: Path
|
|
57
|
+
text: str
|
|
58
|
+
|
|
59
|
+
|
|
52
60
|
@dataclass(frozen=True)
|
|
53
61
|
class Fix:
|
|
54
62
|
"""A fix that can be applied to resolve a rule violation."""
|
|
55
63
|
|
|
56
64
|
title: str
|
|
57
|
-
edits: t.List[TextEdit]
|
|
65
|
+
edits: t.List[TextEdit] = field(default_factory=list)
|
|
66
|
+
create_files: t.List[CreateFile] = field(default_factory=list)
|
|
58
67
|
|
|
59
68
|
|
|
60
69
|
class _Rule(abc.ABCMeta):
|
|
@@ -14,7 +14,15 @@ from sqlmesh.core.linter.helpers import (
|
|
|
14
14
|
get_range_of_model_block,
|
|
15
15
|
read_range_from_string,
|
|
16
16
|
)
|
|
17
|
-
from sqlmesh.core.linter.rule import
|
|
17
|
+
from sqlmesh.core.linter.rule import (
|
|
18
|
+
Rule,
|
|
19
|
+
RuleViolation,
|
|
20
|
+
Range,
|
|
21
|
+
Fix,
|
|
22
|
+
TextEdit,
|
|
23
|
+
Position,
|
|
24
|
+
CreateFile,
|
|
25
|
+
)
|
|
18
26
|
from sqlmesh.core.linter.definition import RuleSet
|
|
19
27
|
from sqlmesh.core.model import Model, SqlModel, ExternalModel
|
|
20
28
|
from sqlmesh.utils.lineage import extract_references_from_query, ExternalModelReference
|
|
@@ -227,7 +235,16 @@ class NoMissingExternalModels(Rule):
|
|
|
227
235
|
|
|
228
236
|
external_models_path = root / EXTERNAL_MODELS_YAML
|
|
229
237
|
if not external_models_path.exists():
|
|
230
|
-
return
|
|
238
|
+
return Fix(
|
|
239
|
+
title="Add external model file",
|
|
240
|
+
edits=[],
|
|
241
|
+
create_files=[
|
|
242
|
+
CreateFile(
|
|
243
|
+
path=external_models_path,
|
|
244
|
+
text=f"- name: '{model_name}'\n",
|
|
245
|
+
)
|
|
246
|
+
],
|
|
247
|
+
)
|
|
231
248
|
|
|
232
249
|
# Figure out the position to insert the new external model at the end of the file, whether
|
|
233
250
|
# needs new line or not.
|
sqlmesh/lsp/context.py
CHANGED
|
@@ -273,13 +273,41 @@ class LSPContext:
|
|
|
273
273
|
if found_violation is not None and found_violation.fixes:
|
|
274
274
|
# Create code actions for each fix
|
|
275
275
|
for fix in found_violation.fixes:
|
|
276
|
-
# Convert our Fix to LSP TextEdits
|
|
277
276
|
changes: t.Dict[str, t.List[types.TextEdit]] = {}
|
|
277
|
+
document_changes: t.List[
|
|
278
|
+
t.Union[
|
|
279
|
+
types.TextDocumentEdit,
|
|
280
|
+
types.CreateFile,
|
|
281
|
+
types.RenameFile,
|
|
282
|
+
types.DeleteFile,
|
|
283
|
+
]
|
|
284
|
+
] = []
|
|
285
|
+
|
|
286
|
+
for create in fix.create_files:
|
|
287
|
+
create_uri = URI.from_path(create.path).value
|
|
288
|
+
document_changes.append(types.CreateFile(uri=create_uri))
|
|
289
|
+
document_changes.append(
|
|
290
|
+
types.TextDocumentEdit(
|
|
291
|
+
text_document=types.OptionalVersionedTextDocumentIdentifier(
|
|
292
|
+
uri=create_uri,
|
|
293
|
+
version=None,
|
|
294
|
+
),
|
|
295
|
+
edits=[
|
|
296
|
+
types.TextEdit(
|
|
297
|
+
range=types.Range(
|
|
298
|
+
start=types.Position(line=0, character=0),
|
|
299
|
+
end=types.Position(line=0, character=0),
|
|
300
|
+
),
|
|
301
|
+
new_text=create.text,
|
|
302
|
+
)
|
|
303
|
+
],
|
|
304
|
+
)
|
|
305
|
+
)
|
|
306
|
+
|
|
278
307
|
for edit in fix.edits:
|
|
279
308
|
uri_key = URI.from_path(edit.path).value
|
|
280
309
|
if uri_key not in changes:
|
|
281
310
|
changes[uri_key] = []
|
|
282
|
-
# Create a TextEdit for the LSP
|
|
283
311
|
changes[uri_key].append(
|
|
284
312
|
types.TextEdit(
|
|
285
313
|
range=types.Range(
|
|
@@ -296,12 +324,15 @@ class LSPContext:
|
|
|
296
324
|
)
|
|
297
325
|
)
|
|
298
326
|
|
|
299
|
-
|
|
327
|
+
workspace_edit = types.WorkspaceEdit(
|
|
328
|
+
changes=changes if changes else None,
|
|
329
|
+
document_changes=document_changes if document_changes else None,
|
|
330
|
+
)
|
|
300
331
|
code_action = types.CodeAction(
|
|
301
332
|
title=fix.title,
|
|
302
333
|
kind=types.CodeActionKind.QuickFix,
|
|
303
334
|
diagnostics=[diagnostic],
|
|
304
|
-
edit=
|
|
335
|
+
edit=workspace_edit,
|
|
305
336
|
)
|
|
306
337
|
code_actions.append(code_action)
|
|
307
338
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=ODmuGfXnsHOG7yOzSoA-XJjd_1OkCpWgVFsH_K0ggDM,528
|
|
3
3
|
sqlmesh/magics.py,sha256=bEzYqXHcM0P3CjyUZ1O9arlmXAdLAhoglKbQ29fD9AE,41842
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -78,9 +78,9 @@ sqlmesh/core/engine_adapter/trino.py,sha256=Tws3GxqnC6BmXFohqru1TDxsgPH-21qV6Oky
|
|
|
78
78
|
sqlmesh/core/linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
sqlmesh/core/linter/definition.py,sha256=JDJTkhByUw4Tr3nF-BOHKFAx_eASQqEqzX6AUVQUz8I,5659
|
|
80
80
|
sqlmesh/core/linter/helpers.py,sha256=Bv11aGRIrnv9Ym9fudy3XQB0k-FvchkLtBTkGI91SEw,6504
|
|
81
|
-
sqlmesh/core/linter/rule.py,sha256=
|
|
81
|
+
sqlmesh/core/linter/rule.py,sha256=nB3o1rHyN44ZOg5ImICP16SeUHimf-12ObdXJjkTGyM,3964
|
|
82
82
|
sqlmesh/core/linter/rules/__init__.py,sha256=gevzfb67vFqckTCoVAe_TBGf6hQ-YtE1_YuGuXyh1L0,77
|
|
83
|
-
sqlmesh/core/linter/rules/builtin.py,sha256=
|
|
83
|
+
sqlmesh/core/linter/rules/builtin.py,sha256=BVBoBr1Ru-DA4VPnwfaodZdVq84afCc9qBgPLmwrfiA,10204
|
|
84
84
|
sqlmesh/core/metric/__init__.py,sha256=H1HmoD5IwN4YWe9iJXyueLYNmTQFZwok5nSWNJcZIBQ,237
|
|
85
85
|
sqlmesh/core/metric/definition.py,sha256=Yd5aVgsZCDPJ43aGP7WqtzZOuuSUtB8uJGVA6Jw9x9M,7201
|
|
86
86
|
sqlmesh/core/metric/rewriter.py,sha256=GiSTHfn2kinqCfNPYgZPRk93JFLzVaaejHtHDQ0yXZI,7326
|
|
@@ -166,7 +166,7 @@ sqlmesh/integrations/github/cicd/controller.py,sha256=0I5mHPz3HBJR5lkR-2J9Bj06Yn
|
|
|
166
166
|
sqlmesh/lsp/api.py,sha256=_lA_buSPZFIoLJuINbS53LbNOOaHp3orb0uFTE3aCqI,2328
|
|
167
167
|
sqlmesh/lsp/commands.py,sha256=7tZPePSH-IwBYmXJPIlqGM7pi4rOCLEtc3fKJglAxZs,72
|
|
168
168
|
sqlmesh/lsp/completions.py,sha256=7Lhboh6xyoMJ3kkHG3aZz1xVbDwKiXeQKdIRj5xlUOA,6674
|
|
169
|
-
sqlmesh/lsp/context.py,sha256=
|
|
169
|
+
sqlmesh/lsp/context.py,sha256=VIL_Xl3II6I79ILZ67UTY9u6OzgkLHDTEpTK91DJxAA,20892
|
|
170
170
|
sqlmesh/lsp/custom.py,sha256=3gfN_z9IXKOhTGkaZX7V5I8WUmI4z1GWe1sViOo92pw,3980
|
|
171
171
|
sqlmesh/lsp/errors.py,sha256=3NMim_5J00Eypz7t8b7XbkBfy8gIsRkeq-VcjD4COtc,1489
|
|
172
172
|
sqlmesh/lsp/helpers.py,sha256=EFc1u3-b7kSv5-tNwmKUDxId72RCLDBnN2lLTgRSzzQ,1020
|
|
@@ -287,7 +287,7 @@ sqlmesh/utils/pydantic.py,sha256=o_NsXbIpDqNpUA1Uc5xF0ZzoXQYYB0DfHwdRxBwXPNk,120
|
|
|
287
287
|
sqlmesh/utils/rich.py,sha256=cwQ5nJ6sgz64xHtoh6_ec7ReV5YpsOGhMtUJnwoRfEI,3549
|
|
288
288
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
289
289
|
sqlmesh/utils/yaml.py,sha256=hvo5lmybYLcIx4p6CQwufS8X4MbwS60lEBnCmYJCXmU,2336
|
|
290
|
-
sqlmesh-0.206.2.
|
|
290
|
+
sqlmesh-0.206.2.dev2.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
291
291
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
292
292
|
web/client/dist/index.html,sha256=SXykdSRNgrT1k6I2dPZPEfpxPjIsi8-yVFijt-naSA4,5472
|
|
293
293
|
web/client/dist/assets/Audits-Jm353fhk.js,sha256=ry6b5IKT3hLAfD5C3T2BqxulfauEV0n0YZ2vsP4eQ_U,1041
|
|
@@ -405,8 +405,8 @@ web/server/api/endpoints/models.py,sha256=kwj0s7uve3iZSMfmjkoPVMFMeY1sD0peTeyrWf
|
|
|
405
405
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
406
406
|
web/server/api/endpoints/plan.py,sha256=bbbY50W_2MsZSTxOHWMKz0tbIm75nsRSlPy8GI2fg9Q,9306
|
|
407
407
|
web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
|
|
408
|
-
sqlmesh-0.206.2.
|
|
409
|
-
sqlmesh-0.206.2.
|
|
410
|
-
sqlmesh-0.206.2.
|
|
411
|
-
sqlmesh-0.206.2.
|
|
412
|
-
sqlmesh-0.206.2.
|
|
408
|
+
sqlmesh-0.206.2.dev2.dist-info/METADATA,sha256=qajqCyJXBIv3CUyhI_xZDP41Mo7zRlMflgxEW0Hs1fs,26685
|
|
409
|
+
sqlmesh-0.206.2.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
410
|
+
sqlmesh-0.206.2.dev2.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
411
|
+
sqlmesh-0.206.2.dev2.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
412
|
+
sqlmesh-0.206.2.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|