diff --git a/litestar/contrib/sqlalchemy/repository/_util.py b/litestar/contrib/sqlalchemy/repository/_util.py index eb1716d1a2..a9e239bc9d 100644 --- a/litestar/contrib/sqlalchemy/repository/_util.py +++ b/litestar/contrib/sqlalchemy/repository/_util.py @@ -21,11 +21,11 @@ def __getattr__(attr_name: str) -> object: ) warn_deprecation( - deprecated_name=f"litestar.contrib.sqlalchemy.repository.{attr_name}", + deprecated_name=f"litestar.contrib.sqlalchemy.repository._util.{attr_name}", version="2.12", kind="import", removal_in="3.0", - info=f"importing {attr_name} from 'litestar.contrib.sqlalchemy.repository' is deprecated, please " + info=f"importing {attr_name} from 'litestar.contrib.sqlalchemy.repository._util' is deprecated, please " f"import it from 'litestar.plugins.sqlalchemy.repository' instead", ) value = globals()[attr_name] = locals()[attr_name] diff --git a/tests/unit/test_contrib/test_sqlalchemy.py b/tests/unit/test_contrib/test_sqlalchemy.py index 64ba6fcdc7..af833809bd 100644 --- a/tests/unit/test_contrib/test_sqlalchemy.py +++ b/tests/unit/test_contrib/test_sqlalchemy.py @@ -357,3 +357,19 @@ def test_deprecated_sqlalchemy_plugins_init_config_sync_handlers() -> None: match="importing autocommit_before_send_handler from 'litestar.contrib.sqlalchemy.plugins.init.config.sync' is deprecated", ): from litestar.contrib.sqlalchemy.plugins.init.config.sync import autocommit_before_send_handler + + +def test_deprecated_sqlalchemy_repository_util_imports() -> None: + purge_module(["litestar.contrib.sqlalchemy.repository._util"], __file__) + with pytest.warns( + DeprecationWarning, + match="importing wrap_sqlalchemy_exception from 'litestar.contrib.sqlalchemy.repository._util' is deprecated", + ): + from litestar.contrib.sqlalchemy.repository._util import wrap_sqlalchemy_exception + + purge_module(["litestar.contrib.sqlalchemy.repository._util"], __file__) + with pytest.warns( + DeprecationWarning, + match="importing get_instrumented_attr from 'litestar.contrib.sqlalchemy.repository._util' is deprecated", + ): + from litestar.contrib.sqlalchemy.repository._util import get_instrumented_attr