Skip to content

fix: open files read-only during format --check - #5961

Open
avakili-voleon wants to merge 1 commit into
SQLMesh:mainfrom
avakili-voleon:fix/format-check-read-only-files
Open

fix: open files read-only during format --check#5961
avakili-voleon wants to merge 1 commit into
SQLMesh:mainfrom
avakili-voleon:fix/format-check-read-only-files

Conversation

@avakili-voleon

@avakili-voleon avakili-voleon commented Aug 20, 2026

Copy link
Copy Markdown

Description

sqlmesh format --check opened model/audit SQL files with r+ even though check mode only reads them. That requires write permission and can fail on read-only filesystems in certain CI setups.

This change opens files in r mode when check=True, and keeps r+ for normal format runs that write back to disk.

Test Plan

  • Added test_format_check_read_only_files — chmods a model file to read-only and verifies format(check=True) completes without error, reports the file needs reformatting, and leaves the file unchanged
  • make style passes
  • make fast-test passes

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)

format --check only reads files to compare content but opened them
with r+, which requires write permission and fails on read-only
filesystems in certain CI setups. Use r for check mode and keep r+
for normal format runs that write back to disk.

Signed-off-by: Amir Vakili <AVakili@Voleon.com>
@avakili-voleon
avakili-voleon marked this pull request as ready for review August 20, 2026 15:25
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.

1 participant