Quantcast
Viewing all articles
Browse latest Browse all 14069

Pycharm type error: Expected type literal got list["Model"]

I write fastapi sqlmodel sqlalchemy project. I got type error in PyCharm:

expected type 'Literal["*"] | QueryableAttribute', got 'list[Account] | None' instead

error was caused by this code:

from sqlalchemy.orm import selectinloadclass CRUDCounterPartyCommon(    CRUDBase[CounterParty, CounterpartyCommonCreateUpdateSchema, CounterpartyCommonCreateUpdateSchema]):    async def get_by_uuid(self, db: AsyncSession, *, _uuid: uuid.UUID) -> Optional[CounterParty]:        counterparty = select(CounterParty).where(CounterParty.id == _uuid).options(selectinload(CounterParty.accounts))

Warning was caused by selectinload. What should I do to solve this problem?

Update

mypy says:

error: Argument 1 to "selectinload" has incompatible type "list[Account] | None"; expected "Literal['*'] | QueryableAttribute[Any]" [arg-type]


Viewing all articles
Browse latest Browse all 14069

Trending Articles