Skip to content

fix: replace ast.Str and drop astor#5850

Merged
StuffbyYuki merged 6 commits into
SQLMesh:mainfrom
lafirm:chore/drop-astor
Jul 3, 2026
Merged

fix: replace ast.Str and drop astor#5850
StuffbyYuki merged 6 commits into
SQLMesh:mainfrom
lafirm:chore/drop-astor

Conversation

@lafirm

@lafirm lafirm commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #5837

  • Updated minimum Python requirement from 3.8 to 3.9 in documentation to match with the pyproject.toml
  • Removed astor from dependencies and mypy overrides in pyproject.toml, using ast.unparse introduced in Python 3.9
  • Replaced all astor.to_source calls with ast.unparse in sqlmesh/core/model/common.py and sqlmesh/utils/metaprogramming.py

Test Plan

  • Updated test expectations in tests/utils/test_metaprogramming.py to match the output format of ast.unparse.

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

@lafirm lafirm force-pushed the chore/drop-astor branch 2 times, most recently from fa54bba to 2fe6224 Compare June 24, 2026 03:00
@StuffbyYuki

Copy link
Copy Markdown
Collaborator

@lafirm Can you check the failed ci test? Also, do you think it's worth considering a brief changelog/release note: python_env payloads feed model data_hash, so users with Python macros may see a one-time fingerprint change on upgrade (e.g. lambda : → lambda:)?

lafirm added 5 commits July 2, 2026 12:13
Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
@lafirm lafirm force-pushed the chore/drop-astor branch from 2baec26 to 77cdbe8 Compare July 2, 2026 09:25
@lafirm

lafirm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Migration note:

Users with Python models or Python macros will have their snapshots automatically re-fingerprinted on sqlmesh migrate. No backfills are triggered. This is a one-time side-effect of replacing astor with ast.unparse for Python source normalisation.

@lafirm

lafirm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@lafirm Can you check the failed ci test? Also, do you think it's worth considering a brief changelog/release note: python_env payloads feed model data_hash, so users with Python macros may see a one-time fingerprint change on upgrade (e.g. lambda : → lambda:)?

sure, I've added a file to migrate the existing rows - hopefully that fixes the CI test. Please let me know where do you want to have this change log (though I already have left a comment in this PR and added a doc string in the migration file)

Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
@lafirm lafirm force-pushed the chore/drop-astor branch from 77cdbe8 to 1131098 Compare July 3, 2026 03:33
@StuffbyYuki StuffbyYuki merged commit b0bc176 into SQLMesh:main Jul 3, 2026
62 of 63 checks passed
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.

Bug: Python 3.14 compatibility error - AttributeError: module 'ast' has no attribute 'Str'

2 participants