Skip to content

Comments

Fix mypy errors with SQLAlchemy 2.0.46+#681

Merged
laughingman7743 merged 3 commits intomasterfrom
fix/680-mypy-sqlalchemy-2.0.46
Feb 21, 2026
Merged

Fix mypy errors with SQLAlchemy 2.0.46+#681
laughingman7743 merged 3 commits intomasterfrom
fix/680-mypy-sqlalchemy-2.0.46

Conversation

@laughingman7743
Copy link
Member

Summary

Closes #680

  • Update type annotations in pyathena/sqlalchemy/compiler.py to match stricter type signatures introduced in SQLAlchemy 2.0.46 (visit_* methods, _render_string_type API change, Function vs FunctionElement, DDL constraint return types, _DialectArgDict type)
  • Add type: ignore comments in pyathena/aio/sqlalchemy/base.py for async adapter protocol mismatches (standard pattern in SQLAlchemy async adapters)
  • Upgrade SQLAlchemy from 2.0.36 to 2.0.46 in uv.lock

Test plan

  • make fmt — passes
  • make chk — 0 mypy errors (was 40)
  • make test-sqla — SQLAlchemy dialect tests (requires AWS credentials)

🤖 Generated with Claude Code

laughingman7743 and others added 3 commits February 21, 2026 22:59
Update type annotations in compiler.py and aio/sqlalchemy/base.py to
match stricter type signatures introduced in SQLAlchemy 2.0.46:

- Update visit_* method signatures in AthenaTypeCompiler to use
  concrete SQLAlchemy types instead of generic Type[Any]
- Update _render_string_type calls to match new API signature
  (name, length, collation) instead of (type_obj, name)
- Change function_argspec parameter from FunctionElement to Function
- Fix DDL constraint visitor return types (str instead of Optional[str])
- Change _DialectArgDict type alias to Mapping[str, Any] to match
  SQLAlchemy's MutableMapping-based _DialectArgDict
- Add type: ignore comments for async adapter protocol mismatches
- Upgrade SQLAlchemy from 2.0.36 to 2.0.46 in uv.lock

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SQLAlchemy 2.0.46 calls cursor._async_soft_close() in the async result
handling path (_ensure_sync_result). Add a no-op implementation matching
the pattern used by SQLAlchemy's own asyncpg adapter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SQLAlchemy 2.0.46 removed BizarroCharacterFKResolutionTest from the
testing suite, causing a NameError during test collection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@laughingman7743 laughingman7743 marked this pull request as ready for review February 21, 2026 14:55
@laughingman7743 laughingman7743 merged commit 52dfba6 into master Feb 21, 2026
5 checks passed
@laughingman7743 laughingman7743 deleted the fix/680-mypy-sqlalchemy-2.0.46 branch February 21, 2026 14:55
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.

Fix mypy errors with SQLAlchemy 2.0.46+ type signature changes

1 participant