Skip to content

Commit e8526bf

Browse files
committed
fix: ensures the symbol is discoverable by documentation tools and provides a helpful error message if instantiated without sqlalchemy installed.
Signed-off-by: Akshat Kumar <akshat230405@gmail.com>
1 parent 6bd7d90 commit e8526bf

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/google/adk/sessions/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
from .base_session_service import BaseSessionService
1516
from .in_memory_session_service import InMemorySessionService
1617
from .session import Session
@@ -21,9 +22,17 @@
2122
from .database_session_service import DatabaseSessionService
2223
except ImportError:
2324
# This handles the case where optional dependencies (like sqlalchemy)
24-
# are not installed. Using a top-level import ensures documentation
25-
# tools can "see" the class.
26-
pass
25+
# are not installed. A placeholder class ensures the symbol is always
26+
# available for documentation tools, providing a clear error message
27+
# at runtime if used without the necessary dependencies.
28+
class DatabaseSessionService:
29+
30+
def __init__(self, *args, **kwargs):
31+
raise ImportError(
32+
'DatabaseSessionService requires sqlalchemy>=2.0, please ensure it is'
33+
' installed correctly.'
34+
)
35+
2736

2837
__all__ = [
2938
'BaseSessionService',

0 commit comments

Comments
 (0)