From d5f72d8790ab4cd8ffb7cdf2ed85e4d9a1319d42 Mon Sep 17 00:00:00 2001 From: Tarcio Date: Fri, 22 May 2026 01:13:37 -0300 Subject: [PATCH] chore(triggers): drop _sqlmodel_compat helper No call-sites left after the worker and crud refactors. The previous filter (``module=r"sqlmodel\.ext\.asyncio\.session"``) never matched anyway: SQLModel emits the deprecation via ``typing_extensions.@deprecated`` with stacklevel=2, so the attributed module was always the caller (our own code), not the sqlmodel module path. Removing the helper keeps the tree honest about the fact that we no longer take the deprecation path at all. --- .../services/triggers/_sqlmodel_compat.py | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/backend/base/langflow/services/triggers/_sqlmodel_compat.py diff --git a/src/backend/base/langflow/services/triggers/_sqlmodel_compat.py b/src/backend/base/langflow/services/triggers/_sqlmodel_compat.py deleted file mode 100644 index 1639b81356..0000000000 --- a/src/backend/base/langflow/services/triggers/_sqlmodel_compat.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Compatibility helpers around SQLModel quirks. - -SQLModel's ``AsyncSession.execute`` is the right choice — and the only -choice — for ``text()`` raw SQL and for ``update()`` / ``delete()`` -constructs. The library still raises a ``DeprecationWarning`` on -every ``execute`` call urging the caller to use ``exec`` instead, even -when ``exec`` does not accept the statement type. The warning is -informational and unrelated to anything actionable on our end. - -This module centralises a tight context manager that silences only -that specific warning, so every trigger module can wrap its raw-SQL -``execute`` calls without each one re-implementing the suppression. - -The filter is narrow on purpose: scoped to the SQLModel module path -so any other ``DeprecationWarning`` from somewhere else still -surfaces. -""" - -from __future__ import annotations - -import warnings -from contextlib import contextmanager -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from collections.abc import Iterator - - -@contextmanager -def suppress_sqlmodel_exec_warning() -> Iterator[None]: - """Silence SQLModel's 'use exec()' nudge for the wrapped block. - - Use around the few legitimate ``session.execute(...)`` calls we - have (raw SQL via :func:`sqlalchemy.text`, or ORM - ``update()`` / ``delete()`` constructs that :meth:`AsyncSession.exec` - explicitly does not accept). - """ - with warnings.catch_warnings(): - warnings.filterwarnings( - "ignore", - category=DeprecationWarning, - module=r"sqlmodel\.ext\.asyncio\.session", - ) - yield