Skip to content

feat: lint rule no missing external will create file#5078

Merged
benfdking merged 2 commits intomainfrom
codex/add-file-creation-to-linter
Jul 31, 2025
Merged

feat: lint rule no missing external will create file#5078
benfdking merged 2 commits intomainfrom
codex/add-file-creation-to-linter

Conversation

@benfdking
Copy link
Contributor

Summary

  • extend linter Fix to support creating files
  • add CreateFile dataclass
  • enhance NoMissingExternalModels rule to create external_models.yaml if missing
  • surface file creation edits in LSP code actions
  • test linter and LSP behavior for file creation

Testing

  • pytest tests/core/linter/test_builtin.py::test_no_missing_external_models -q
  • pytest tests/lsp/test_code_actions.py::test_code_actions_create_file -q
  • pytest tests/core/linter/test_builtin.py::test_no_missing_external_models_with_existing_file_ending_in_newline -q
  • pytest tests/core/linter/test_builtin.py::test_no_missing_external_models_with_existing_file_not_ending_in_newline -q
  • pytest tests/lsp/test_code_actions.py::test_code_actions_with_linting -q

https://chatgpt.com/codex/tasks/task_e_688b3aa3749883309ac7292ddb5440cd

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CreateFile dataclass to support file creation operations
  • Enhances the NoMissingExternalModels rule to automatically create external_models.yaml when 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

@benfdking benfdking changed the title Enable linter fixes to create new files feat: lint rule no missing external will create file Jul 31, 2025
- 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
@benfdking benfdking force-pushed the codex/add-file-creation-to-linter branch from bf84dd9 to d23c057 Compare July 31, 2025 10:30
@benfdking benfdking merged commit b448d1c into main Jul 31, 2025
27 checks passed
@benfdking benfdking deleted the codex/add-file-creation-to-linter branch July 31, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants