Skip to content

BUG: Instructions from Warning of Depreacted seems wrong #4117

Open
@YuanhengZ

Description

@YuanhengZ

Description

from litestar.contrib.sqlalchemy.repository import SQLAlchemyAsyncRepository  # Async CRUD operations

Give following warning:

..\..\.conda\envs\backery-back-end\Lib\site-packages\litestar\contrib\sqlalchemy\repository\__init__.py:37
Lib\site-packages\litestar\contrib\sqlalchemy\repository\__init__.py:37: DeprecationWarning: Import of deprecated import 'litestar.contrib.sqla
lchemy.repository.SQLAlchemyAsyncRepository'. Deprecated in litestar 2.12. This import will be removed in 3.0. importing SQLAlchemyAsyncRepository from 'litestar.contrib.sqlalchemy.repository' is deprecated, please import it from 'litestar.plugins.sqlalchemy.repository' instead
    warn_deprecation(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

However, change from

from litestar.contrib.sqlalchemy.repository import SQLAlchemyAsyncRepository  # Async CRUD operations
# to
from litestar.plugins.sqlalchemy.repository import SQLAlchemyAsyncRepository   # Async CRUD operations

Outputs:

sql_manage\relation.py:22: in <module>
    from litestar.plugins.sqlalchemy.repository import SQLAlchemyAsyncRepository  # Async CRUD operations
E   ModuleNotFoundError: No module named 'litestar.plugins.sqlalchemy.repository'; 'litestar.plugins.sqlalchemy' is not a package

I have to use

from litestar.plugins.sqlalchemy import repository  # Async CRUD operations

then call it like

repository.SQLAlchemyAsyncRepository

URL to code causing the issue

No response

MCVE

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

No response

Logs


Litestar Version

I am running

litestar                  2.15.1
litestar-htmx             0.4.1

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛This is something that is not working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions