From e6dfb0430ef7e3a388b1fb573a37dc74379baa9b Mon Sep 17 00:00:00 2001 From: Oleg Ovcharuk Date: Tue, 2 Jun 2026 20:31:30 +0300 Subject: [PATCH] Fix dialect import on SQLAlchemy 1.4 `@reflection.cache` on SQLAlchemy 1.4 regenerates the wrapped method from its source string and exec's it in a namespace that only contains the target/fn symbols. The `**kw: Any` annotation on get_view_names and get_view_definition was preserved literally in that source and failed to evaluate (NameError: name 'Any' is not defined), breaking `import ydb_sqlalchemy` entirely on 1.4. Drop the kwargs annotation to match the other reflection methods. No behavior change on SQLAlchemy 2.0. Fixes #112 --- CHANGELOG.md | 2 ++ ydb_sqlalchemy/sqlalchemy/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc5ba3f..b917358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Fix dialect import failure on SQLAlchemy 1.4 (drop kwargs annotation on view reflection methods) + ## 0.1.20 ## * Support YDB view reflection diff --git a/ydb_sqlalchemy/sqlalchemy/__init__.py b/ydb_sqlalchemy/sqlalchemy/__init__.py index 788ae18..7c81153 100644 --- a/ydb_sqlalchemy/sqlalchemy/__init__.py +++ b/ydb_sqlalchemy/sqlalchemy/__init__.py @@ -265,14 +265,14 @@ def _describe_table(self, connection, table_name, schema=None) -> ydb.TableDescr raise NoSuchTableError(qt) from e @reflection.cache - def get_view_names(self, connection, schema=None, **kw: Any): + def get_view_names(self, connection, schema=None, **kw): self._ensure_schema_unsupported(schema) raw_conn = connection.connection return raw_conn.get_view_names() @reflection.cache - def get_view_definition(self, connection, view_name, schema=None, **kw: Any): + def get_view_definition(self, connection, view_name, schema=None, **kw): self._ensure_schema_unsupported(schema) quoted_view_name = self.identifier_preparer.quote(view_name)