Conversation
Guard sqlmodel import with find_spec
Ensure that computed var dependencies can be determined on python3.14
There was a problem hiding this comment.
Greptile Overview
Summary
This PR adds Python 3.14 compatibility to the Reflex framework following Python 3.14's release on October 7, 2025. The changes primarily address PEP 649 (Deferred Evaluation of Annotations), which fundamentally changes how type annotations are handled in Python 3.14.The core technical changes involve replacing direct __annotations__ access with proper annotation resolution mechanisms:
-
Type Hint Resolution: Multiple files now use
get_type_hints()from the typing module instead of directly accessing__annotations__, ensuring forward references are properly resolved -
Lazy Annotations Support: Several metaclasses and utility functions now check for the new
__annotate_func__attribute introduced in Python 3.14, which provides deferred annotation evaluation -
Bytecode Compatibility: The dependency tracking system has been updated to handle the new
LOAD_FAST_BORROWbytecode opcode introduced in Python 3.14 -
Build Environment: CI workflows have been updated to test against Python 3.14, and PyO3 compatibility has been ensured through environment variable configuration
These changes maintain full backward compatibility with older Python versions while enabling the framework to work with Python 3.14's new annotation system. The modifications span critical areas including state management, model definitions, field resolution, and the build pipeline.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| reflex/utils/pyi_generator.py | 5/5 | Replaces direct __annotations__ access with get_type_hints() for Python 3.14 compatibility |
| reflex/components/field.py | 5/5 | Adds support for Python 3.14's __annotate_func__ lazy annotation mechanism in metaclass |
| reflex/state.py | 5/5 | Updates computed variable shadow checking to use get_type_hints() instead of direct annotation access |
| reflex/vars/base.py | 5/5 | Implements Python 3.14 lazy annotation support in BaseStateMeta metaclass |
| reflex/vars/dep_tracking.py | 5/5 | Adds support for new LOAD_FAST_BORROW bytecode opcode in dependency tracking |
| reflex/base.py | 5/5 | Applies new ModelMetaclassLazyAnnotations metaclass for Python 3.14 compatibility |
| reflex/model.py | 5/5 | Updates deprecation version from 0.8.0 to 0.8.15 for primary key override warning |
| .github/workflows/unit_tests.yml | 4/5 | Adds Python 3.14 to CI matrix but inconsistent between jobs (main vs macOS) |
| .github/workflows/integration_tests.yml | 4/5 | Adds Python 3.14 to some test jobs but not others, creating incomplete coverage |
| .github/actions/setup_build_env/action.yml | 4/5 | Adds PyO3 forward compatibility environment variable for Python 3.14 support |
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it implements well-established compatibility patterns for Python version upgrades
- Score reflects thorough compatibility implementation across critical components, with only minor CI workflow inconsistencies
- Pay close attention to the GitHub Actions workflow files which have incomplete Python 3.14 coverage across all test jobs
Additional Comments (1)
-
.github/workflows/unit_tests.yml, line 80 (link)style: The macOS unit tests job doesn't include Python 3.14, creating inconsistent test coverage. Consider adding '3.14' here to match the main unit-tests job.
10 files reviewed, 1 comment
CodSpeed Performance ReportMerging #5859 will improve performances by 27.84%Comparing Summary
Benchmarks breakdown
|
|
turns out there actually is a nice api for this, will update |
44046af to
2448c78
Compare
Compatibility for python3.14 (released October 7, 2025)