Skip to content

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

@wmthompson1-skills

Description

@wmthompson1-skills

"read" dialect eg. parse_one(sql, read="spark")
"write" dialect eg. ast.sql(dialect="duckdb")

Description:

When running SQLMesh under a Python 3.14 environment, the application crashes during startup or compilation with an AttributeError. The error stems from a dependency or internal code referencing ast.Str, which has been completely removed in Python 3.14. [2]

Steps to Reproduce:

  1. Install SQLMesh on an environment running Python 3.14.
  2. Attempt to run sqlmesh plan, sqlmesh run, or initialize a context.
  3. Observe the AttributeError trace indicating module 'ast' has no attribute 'Str'. [2, 3]

Expected Behavior:

The code should dynamically check for Python version capabilities or transition fully to using ast.Constant (which replaced ast.Str, ast.Num, ast.Bytes, ast.NameConstant, and ast.Ellipsis since Python 3.8 and was finalized for removal in 3.14). [2, 4]

Environment Info:

  • OS: Windows
  • Python Version: 3.14+
  • SQLMesh Version: 0.231.1 (or latest)
  • SQLGlot Version: 28.10.1 [2]

Suggested Fix:

To ensure backwards compatibility while supporting Python 3.14+, instances of ast.Str should either be handled via an explicit version or attribute check, or mapped directly to ast.Constant.
As a temporary fallback in the codebase's entry point:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions