-
-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
I have a backend application using Python 3.14 and FastAPI. The project does not start due to a problem in the annotations, which are evaluated at runtime. The problem is in this code:
class SQLAlchemyAsyncRepository(SQLAlchemyAsyncRepositoryProtocol[ModelT], FilterableRepository[ModelT]):
def __init__(
self,
*,
statement: Optional[Select[tuple[ModelT]]] = None,
session: Union[AsyncSession, async_scoped_session[AsyncSession]],
auto_expunge: bool = False,
auto_refresh: bool = True,
auto_commit: bool = False,
order_by: Optional[Union[list[OrderingPair], OrderingPair]] = None,
error_messages: Optional[Union[ErrorMessages, EmptyType]] = Empty,
load: Optional[LoadSpec] = None,
execution_options: Optional[dict[str, Any]] = None,
wrap_exceptions: bool = True,
uniquify: Optional[bool] = None,
count_with_window_function: Optional[bool] = None,
**kwargs: Any,
) -> None: ...Here, list becomes a method of the repository class rather than a global object. I replaced the line in the annotation to check this as follows:
order_by: Optional[Union[print(list), OrderingPair]] = None,In the terminal, I received: <function SQLAlchemyAsyncRepository.list at 0x10e3a2cf0>.
URL to code causing the issue
No response
MCVE
from advanced_alchemy.repository import SQLAlchemyAsyncRepository
getattr(SQLAlchemyAsyncRepository.__init__, "__annotations__", None)Steps to reproduce
1. Run codeScreenshots
Logs
Traceback (most recent call last):
File "/Users/denis/PycharmProjects/project/backend/src/payloads/repository.py", line 29, in <module>
getattr(Repository.__init__, "__annotations__", None)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/denis/PycharmProjects/project/backend/.venv/lib/python3.14/site-packages/advanced_alchemy/repository/_async.py", line 460, in __annotate__
order_by: print(list) | list[OrderingPair] | OrderingPair | None = None,
~~~~^^^^^^^^^^^^^^
TypeError: 'function' object is not subscriptablePackage Version
advanced-alchemy v1.8.2
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working