Skip to content

Typing issue on selectinload() expected "Literal['*'] | QueryableAttribute[Any]" #871

Answered by itsbekas
copdips asked this question in Questions
Discussion options

You must be logged in to vote

You're both right, I apologize. For some reason mypy wasn't picking up that error on my side.

In the meantime, I think I found the issue:
By changing team: Team | None to team: Mapped[Team | None] (note that Mapped is imported from sqlalchemy.orm), the error seems to disappear, while the example still works as intended. However, I'm not sure if this has any side effects, namely with Pydantic (assuming you're using FastAPI), so you might want to check that, just to be sure.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@copdips
Comment options

Comment options

You must be logged in to vote
4 replies
@AlPashy
Comment options

@copdips
Comment options

@itsbekas
Comment options

Answer selected by copdips
@copdips
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
3 participants