feat: lint rule no missing external will create file#5078
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR extends the linter's Fix mechanism to support file creation in addition to text edits. The main purpose is to enable automatic creation of missing configuration files when linting detects missing dependencies.
- Adds
CreateFiledataclass to support file creation operations - Enhances the
NoMissingExternalModelsrule to automatically createexternal_models.yamlwhen missing - Integrates file creation capabilities into LSP code actions for seamless editor support
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sqlmesh/core/linter/rule.py | Adds CreateFile dataclass and extends Fix to include file creation operations |
| sqlmesh/core/linter/rules/builtin.py | Updates NoMissingExternalModels rule to create external models file when missing |
| sqlmesh/lsp/context.py | Enhances LSP code actions to handle file creation operations |
| tests/core/linter/test_builtin.py | Tests the new file creation functionality in the linter |
| tests/lsp/test_code_actions.py | Tests LSP integration for file creation code actions |
- 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
bf84dd9 to
d23c057
Compare
georgesittas
approved these changes
Jul 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
external_models.yamlif missingTesting
pytest tests/core/linter/test_builtin.py::test_no_missing_external_models -qpytest tests/lsp/test_code_actions.py::test_code_actions_create_file -qpytest tests/core/linter/test_builtin.py::test_no_missing_external_models_with_existing_file_ending_in_newline -qpytest tests/core/linter/test_builtin.py::test_no_missing_external_models_with_existing_file_not_ending_in_newline -qpytest tests/lsp/test_code_actions.py::test_code_actions_with_linting -qhttps://chatgpt.com/codex/tasks/task_e_688b3aa3749883309ac7292ddb5440cd