#Advanced-Alchemy TypeError for SQLAlchemyPlugin
1 messages · Page 1 of 1 (latest)
can you try from advanced_alchemy.extensions.litestar import SQLAlchemyPlugin?
still gives me the error
from advanced_alchemy.extensions.litestar import SQLAlchemyPlugin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/XXX/.pixi/envs/default/lib/python3.11/site-packages/advanced_alchemy/extensions/litestar/init.py", line 4, in <module>
from advanced_alchemy.extensions.litestar import providers, session, store
File "/XXX/.pixi/envs/default/lib/python3.11/site-packages/advanced_alchemy/extensions/litestar/providers.py", line 66, in <module>
AsyncServiceT_co = TypeVar("AsyncServiceT_co", bound=SQLAlchemyAsyncRepositoryService[Any], covariant=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/XXX/.pixi/envs/default/lib/python3.11/typing.py", line 379, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/XXX/.pixi/envs/default/lib/python3.11/typing.py", line 1864, in class_getitem
_check_generic(cls, params, len(cls.parameters))
File "/XXX/.pixi/envs/default/lib/python3.11/typing.py", line 293, in _check_generic
raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments for {cls};"
TypeError: Too few arguments for <class 'advanced_alchemy.service._async.SQLAlchemyAsyncRepositoryService'>; actual 1, expected 2
I am using python 3.11, and advanced alchemy 1.6
TypeError: Too few arguments for <class 'advanced_alchemy.service._async.SQLAlchemyAsyncRepositoryService'>; actual 1, expected 2
You are not initializing it correctly
https://docs.advanced-alchemy.litestar.dev/latest/usage/frameworks/litestar.html#repository-and-service-layer
still get the same error when doing all 3 of them:
from advanced_alchemy.extensions.litestar import (AsyncSessionConfig,SQLAlchemyAsyncConfig,SQLAlchemyPlugin)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/davidkamkar/Documents/AlphaPoseApp/.pixi/envs/default/lib/python3.11/site-packages/advanced_alchemy/extensions/litestar/init.py", line 4, in <module>
from advanced_alchemy.extensions.litestar import providers, session, store
File "/Users/davidkamkar/Documents/AlphaPoseApp/.pixi/envs/default/lib/python3.11/site-packages/advanced_alchemy/extensions/litestar/providers.py", line 66, in <module>
AsyncServiceT_co = TypeVar("AsyncServiceT_co", bound=SQLAlchemyAsyncRepositoryService[Any], covariant=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/Users/davidkamkar/Documents/AlphaPoseApp/.pixi/envs/default/lib/python3.11/typing.py", line 379, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/Users/davidkamkar/Documents/AlphaPoseApp/.pixi/envs/default/lib/python3.11/typing.py", line 1864, in class_getitem
_check_generic(cls, params, len(cls.parameters))
File "/Users/davidkamkar/Documents/AlphaPoseApp/.pixi/envs/default/lib/python3.11/typing.py", line 293, in _check_generic
raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments for {cls};"
TypeError: Too few arguments for <class 'advanced_alchemy.service._async.SQLAlchemyAsyncRepositoryService'>; actual 1, expected 2
You still have the same error, please refer to docs linked above and try to understand how to configure it
Ok i'll try to figure out the step I need to do before importing the library
Can you share some code? I don't have any context on the error above.
All I am doing is the first step in the document specifically
from advanced_alchemy.extensions.litestar import (
AsyncSessionConfig,
SQLAlchemyAsyncConfig,
SQLAlchemyPlugin,
)
session_config = AsyncSessionConfig(expire_on_commit=False)
alchemy_config = SQLAlchemyAsyncConfig(
connection_string="sqlite+aiosqlite:///test.sqlite",
before_send_handler="autocommit",
session_config=session_config,
create_all=True,
)
alchemy = SQLAlchemyPlugin(config=alchemy_config)
My error is in Just importing SQLAlchemyPlugin
Still working following all steps in the doc by updating my whole app and running through litestar to hopefully resolve this issue
in case it helps, here is the same app in litestar with AA and the equivalent in fastapi: https://github.com/litestar-org/advanced-alchemy/blob/main/examples/litestar/litestar_service.py and https://github.com/litestar-org/advanced-alchemy/blob/main/examples/fastapi/fastapi_service_full.py