Skip to content

fix: import on SQLAlchemy 2.1, which removed FallbackAsyncAdaptedQueuePool - #79

Merged
AlexeyShalaev merged 1 commit into
masterfrom
fix/sqlalchemy-2-1-pool-import
Nov 2, 2026
Merged

AlexeyShalaev merged 1 commit into
masterfrom
fix/sqlalchemy-2-1-pool-import

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

Fixes #78.

import sqlalchemy_foundation_kit failed on SQLAlchemy 2.1, which the metadata (sqlalchemy[asyncio]>=2.0.35,<3.0.0) lets every fresh install pick: base/engine.py imported FallbackAsyncAdaptedQueuePool, and SQLAlchemy 2.1 removed it together with the async_fallback mode it served.

Change

  • base/engine.py registers fallback_async_adapted_queue only when sqlalchemy.pool still has the class (SQLAlchemy 2.0). On 2.1 the kit imports, the five other built-ins resolve as before, and resolving fallback_async_adapted_queue raises the registry's usual ValueError with the list of available pools. Nothing changes on SQLAlchemy 2.0.
  • A regression test imports the engine module in a fresh interpreter after removing the class from sqlalchemy.pool, the way 2.1 looks to the kit. It fails on master with the ImportError from the issue and passes with the change.
  • The tests that exercise the fallback pool itself are skipped where SQLAlchemy no longer has it, instead of breaking the whole module at import.
  • CI gets a job, All tests (newest SQLAlchemy), that runs uv lock --upgrade-package sqlalchemy and the whole suite, so the next SQLAlchemy release that breaks the kit shows up in CI rather than in a user's install. It is part of All checks passed. uv.lock stays on 2.0.49, so the existing jobs keep testing 2.0.
  • docs/agents.md and the PoolSettings docstring say that fallback_async_adapted_queue exists only on SQLAlchemy 2.0.

Checks run locally

  • uv run ruff check ., uv run ruff format --check ., uv run mypy sqlalchemy_foundation_kit: clean; pre-commit on the changed files: passed.
  • The regression test on master: fails with ImportError: cannot import name 'FallbackAsyncAdaptedQueuePool' from 'sqlalchemy.pool'; with the change it passes.
  • Whole suite on the locked SQLAlchemy 2.0.49 with coverage (uv run pytest --cov=sqlalchemy_foundation_kit --cov-fail-under=90): 665 passed, coverage 94.24%.
  • Whole suite on SQLAlchemy 2.1.6 (uv run --with "sqlalchemy[asyncio]==2.1.6" pytest, integration tests on postgres:17-alpine included): 662 passed, 3 skipped. The three skipped tests are the ones that exercise FallbackAsyncAdaptedQueuePool itself.
  • uv lock --upgrade-package sqlalchemy, the new CI job's first step, resolves 2.1.6 (uv.lock was restored afterwards and is not part of this change).

…ePool

Register fallback_async_adapted_queue only when sqlalchemy.pool still has
the class (SQLAlchemy 2.0). On 2.1 the kit imports, the other built-in
pools resolve as before, and the removed name raises the registry's
ValueError. A CI job now runs the whole suite on the newest SQLAlchemy
that pyproject.toml allows.

Fixes #78
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AlexeyShalaev
AlexeyShalaev merged commit 3fe20f2 into master Nov 2, 2026
9 checks passed
@AlexeyShalaev
AlexeyShalaev deleted the fix/sqlalchemy-2-1-pool-import branch November 2, 2026 06:59
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.

Importing the kit fails on SQLAlchemy 2.1: FallbackAsyncAdaptedQueuePool no longer exists

1 participant