Skip to content

Add local lint option#5876

Open
EthanVieira wants to merge 7 commits into
SQLMesh:mainfrom
EthanVieira:local-lint-option
Open

Add local lint option#5876
EthanVieira wants to merge 7 commits into
SQLMesh:mainfrom
EthanVieira:local-lint-option

Conversation

@EthanVieira

@EthanVieira EthanVieira commented Jul 1, 2026

Copy link
Copy Markdown

Description

As mentioned in #5182, the lint command still requires the remote state to resolve references in the multi-repo case. These changes add an optional --local option to the lint command so it is runnable without a reachable state backend. This is useful for faster lint iterations in repositories where all referenced models are available locally.

In multi-repo setups, or when linting only a subset of projects, --local may produce additional linting errors because SQLMesh will not resolve references or schemas from models that exist only in remote state.

Updated the linter guide and CLI reference to document the new flag and caveat.

Resolves: #5182

Test Plan

  • Added CLI test coverage for sqlmesh lint --local to verify Context is constructed with load_state=False and state sync is not accessed.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

evieira and others added 5 commits July 1, 2026 11:07
Signed-off-by: evieira <t01etvi@tryg.dk>
Signed-off-by: evieira <t01etvi@tryg.dk>
Signed-off-by: evieira <t01etvi@tryg.dk>
Signed-off-by: evieira <t01etvi@tryg.dk>
@StuffbyYuki StuffbyYuki self-requested a review July 16, 2026 03:14

@StuffbyYuki StuffbyYuki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@EthanVieira Thanks for this PR!

No blocker, but one thing -- The "--local" in sys.argv gate is understandable given Context is built in the parent callback before the subcommand runs, but it means Click can accept --local while behavior only changes when argv matches (hence the test monkeypatch). A brief comment at the gate (or a slightly cleaner early-parse / root-level wiring) would help future readers.

Once ci tests passed, I'll merge the PR (you prob just need to rebase)

Let me know what you think!

@EthanVieira

Copy link
Copy Markdown
Author

@EthanVieira Thanks for this PR!

No blocker, but one thing -- The "--local" in sys.argv gate is understandable given Context is built in the parent callback before the subcommand runs, but it means Click can accept --local while behavior only changes when argv matches (hence the test monkeypatch). A brief comment at the gate (or a slightly cleaner early-parse / root-level wiring) would help future readers.

Once ci tests passed, I'll merge the PR (you prob just need to rebase)

Let me know what you think!

Agreed! Added some earlier parsing and comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlmesh format requires DB connection

3 participants