[Feature] Support Python 3.12+ syntax in Snowpark Python models
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this your first time submitting a feature request?
- [x] I have read the [expectations for open source contributors](https://docs.getdbt.com/docs/contributing/oss-expectations)
- [x] I have searched the existing issues, and I could not find an existing issue for this feature
- [x] I am requesting a straightforward extension of existing dbt functionality, rather than a Big Idea better suited to a discussion
### Describe the feature
## Summary
Using Python 3.12+ syntax in a Snowpark dbt Python model causes a parse-time failure in dbt Cloud, even when `python_version = "3.12"` is set. Snowflake and Snowpark both support Python 3.12 and 3.13, so users reasonably expect to be able to use modern Python syntax in their models.
## Error
```
Parsing Error
invalid syntax (my_python_model.py, line 13)
type MyType = str
```
This error occurs when using a [PEP 695](https://peps.python.org/pep-0695/) type alias statement (`type X = Y`), introduced in Python 3.12.
## Environment
| | |
|---|---|
| dbt version | 2026.4.28+9052846 (Latest release track) |
| dbt Python | 3.11.15 (`/venv/dbt-latest/bin/python`) |
| Platform | dbt Cloud |
| Adapter | dbt-snowflake 1.11.0 |
| `python_version` config | `"3.12"` |
## Root cause
In `core/dbt/parser/models.py`, the Python model parser calls `ast.parse()` on the model source file:
```python
# core/dbt/parser/models.py:197
try:
tree = ast.parse(node.raw_code, filename=node.original_file_path)
except SyntaxError as exc:
raise PythonParsingError(exc, node=node) from exc
```
Because no `feature_version` is passed, `ast.parse()` validates the file against the Python version of dbt's own runtime (3.11.15 in dbt Cloud). This means any syntax introduced in Python 3.12 — even if it has no runtime effect and would be handled correctly by Snowflake — is rejected before execution reaches the warehouse.
## Suggested direction
Python's `ast.parse()` accepts a `feature_version` argument (available since Python 3.8) that allows parsing source files as a specific Python version, independent of the interpreter version. It may be worth exploring whether `feature_version` could be derived from the model's `python_version` config and passed through here — though we appreciate there may be implications for the broader parser and AST visitor logic we're not aware of.
At minimum, it would be helpful if the docs clarified that the 3.9–3.11 ceiling is a dbt parser constraint rather than a Snowflake/Snowpark one, so users understand why `python_version = "3.12"` doesn't work as expected.
### Describe alternatives you've considered
## Workaround
Avoid Python 3.12+ statement-level syntax. For example, replace PEP 695 `type` aliases with `typing.TypeAlias`:
```python
# instead of (Python 3.12+ only):
type MyType = str
# use (Python 3.10+ compatible):
from typing import TypeAlias
MyType: TypeAlias = str
```
### Who will this benefit?
## Why this matters
Snowflake and Snowpark have moved ahead of dbt's parser:
| | Supported Python versions |
|---|---|
| Snowflake runtime | 3.9 – 3.13 |
| snowflake-snowpark-python | 3.9 – 3.13 |
| dbt Cloud runtime | 3.11.15 |
| dbt parser ceiling | Effectively 3.11 (no `feature_version`) |
The dbt docs note that `python_version` supports 3.9–3.11, but this limitation comes from dbt's parser, not from Snowflake or Snowpark. Users setting `python_version = "3.12"` would reasonably expect that to work end to end.
### Are you interested in contributing this feature?
I'd love to!
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.