#Advanced-Alchemy TypeError for SQLAlchemyPlugin

1 messages · Page 1 of 1 (latest)

onyx belfry
#

looks like just import litestar.plugins.sqlalchemy has this issue

atomic ermine
#

can you try from advanced_alchemy.extensions.litestar import SQLAlchemyPlugin?

onyx belfry
#

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

atomic ermine
onyx belfry
#

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

atomic ermine
#

You still have the same error, please refer to docs linked above and try to understand how to configure it

onyx belfry
#

Ok i'll try to figure out the step I need to do before importing the library

haughty isle
#

Can you share some code? I don't have any context on the error above.

onyx belfry
#

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

haughty isle