Repository navigation
Add support for SQLAlchemy 2.1 - #405
Conversation
SQLAlchemy 2.1.1 is the current release, and Continuum failed to import on it: 2.1 made attributes.ScalarAttributeImpl and register_attribute private, and the generic relationship in _compat subclasses and calls them. Resolve both from whichever name the installed version exposes. Widen the pin to <2.2 and split the CI and tox SQLAlchemy legs into 1.4, 2.0 and 2.1; SQLAlchemy 2.1 requires Python 3.11+, so py3.10 is excluded from the 2.1 leg. uv.lock now resolves SQLAlchemy 2.0.54 on Python 3.10 and 2.1.1 on 3.11+. Behavior fixes found while porting: TransactionFactory.create_class resolved user_cls inside the class body, so registry, Base and user_cls leaked onto the Transaction model; registry shadowed the declarative registry and 2.1 raises an SAWarning for it. The lookup now runs before the class body. prevent_reentry never reset its flag when configuration raised, which silently disabled version model building for every later configure_mappers() and turned one failing test into 692 failures. count_versions() runs its textual query under no_autoflush: 2.1 autoflushes Core statements in Session.execute (sqlalchemy#9809), which made the helper flush pending changes and count the version it wrote. GenericAttributeImpl detected the 2.0.22 constructor change by int-parsing sa.__version__, which raises on pre-releases such as 2.1.0rc2. It now checks the positional argument count instead. Test harness: the module-level simplefilter meant to turn SAWarnings into errors was discarded by pytest's per-phase catch_warnings and never fired; it is now pytest filterwarnings. The Postgres test URL names psycopg2 explicitly because 2.1 maps postgresql:// to psycopg 3. Verified locally: full suite on sqlite, postgres, postgres-native and mysql under SQLAlchemy 1.4.54, 2.0.54 and 2.1.1 with SAWarnings as errors, postgres and postgres-native on 2.1.1 with psycopg 3, ruff, and a strict Zensical docs build. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (15)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe project now supports SQLAlchemy versions below 2.2, including SQLAlchemy 2.1. The changes update SQLAlchemy API compatibility and Transaction model setup, prevent autoflush during version counts, reset re-entry state after exceptions, and revise CI, tests, and project documentation. ChangesSQLAlchemy support and behavior
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Merge Risk: ⚪ Minimal · up to No identified issue prevents merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The inspected changes preserve the existing relationship and user-attribution paths, with no identified new security exposure. Compatibility and recovery after an interrupted model build remain the main uncertainties. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 23.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 8 files. (7 skipped: 7 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
The lint job installed the lint dependency group without the lockfile, so it always pulled the newest ruff. Since ruff 0.16, which formats Python code blocks inside Markdown, the job has failed on main even though the pinned ruff (0.15.20 in uv.lock and .pre-commit-config.yaml) passes. Run the pinned pre-commit hooks with pre-commit/action instead, as qualytics-cli does. CI now also enforces the check-yaml, check-toml, end-of-file and trailing-whitespace hooks, and Dependabot already bumps the hook revs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
|
@greptileai review |
Description
Adds support for SQLAlchemy 2.1 (current release: 2.1.1). The supported range becomes
SQLAlchemy>=1.4.53,<2.2. SQLAlchemy 2.1 requires Python 3.11+, so installs on Python 3.10 continue to resolve to 2.0.x.Compatibility fixes
_compat.py: 2.1 madeattributes.ScalarAttributeImplandregister_attributeprivate, which brokeimport sqlalchemy_continuum. Both are now resolved from whichever name the installed version exposes.count_versions(): 2.1 autoflushes Core statements inSession.execute()(sqlalchemy#9809), so the helper began flushing pending changes and counting the version that flush wrote. It now runs undersession.no_autoflush, matching 1.4 and 2.0.GenericAttributeImpldetected the 2.0.22 constructor change by int-parsingsa.__version__, which raisesValueErroron pre-releases such as2.1.0rc2. It now checks the positional argument count: 4 on 1.4 through 2.0.21, and 3 on 2.0.22 and later. This was checked against 1.4.53, 2.0.0, 2.0.21, 2.0.22, 2.1.0 and 2.1.1.Latent bugs that 2.1 exposed
TransactionFactory.create_classresolveduser_clsinside the class body, soregistry,Baseanduser_clsbecame attributes ofTransaction.Transaction.registryshadowed the declarative registry, and 2.1 raises anSAWarningfor it.prevent_reentrydidn't reset its flag when configuration raised. That silently disabled version model building for every laterconfigure_mappers(): during the port, one failing configure caused 692 unrelated test failures.CI and tooling
uv.lockis refreshed: SQLAlchemy 2.0.54 on Python 3.10 and 2.1.1 on 3.11+.postgresql://to psycopg 3.warnings.simplefilterintests/__init__.py, and pytest discards those. It is now afilterwarningsentry inpyproject.toml, so it is actually enforced.Verification (local)
ruff check,ruff format --checkandzensical build --clean --strictpass.Possible follow-up (not in this PR): CI only exercises psycopg2. A psycopg 3 leg on SQLAlchemy 2.0+ would cover 2.1's new default driver.
Checklist
This pull request is:
🤖 Generated with Claude Code
Summary by CodeRabbit
generic_relationshipcompatibility with SQLAlchemy prereleases.count_versions()to avoid flushing pending session changes, keeping behavior consistent across supported SQLAlchemy versions.