| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I have similar errors: repository.py:124: error: No overload variant of "select" matches argument types "Optional[bool]", "Function[NullType]" [call-overload] repository.py:147: error: No overload variant of "exec" of "Session" matches argument type "Function[NullType]" [call-overload] repository.py:151: error: No overload variant of "exec" of "Session" matches argument type "Function[NullType]" [call-overload] line 124: select(GameSession.user_won, func.count())line 147: session.exec(func.avg(avg_query.subquery().c.count))line 151: session.exec(
func.avg(
avg_query.filter(GameSession.user_won == True)
.subquery()
.c.count
)
) |
|
You guys are not alone. Only solution at the moment: import select from sqlalchemy. But this only solves this, because sqlalchemy has no type annotations. Any other solution found yet? Or is the way of doing things here not the way it should be? |
|
To anyone who comes across this issue as I did, the solution apparently is to wrap column expressions with the col() wrapper as documented here: https://sqlmodel.tiangolo.com/tutorial/where/#type-annotations-and-errors. For example: from sqlmodel import col
...
select(col(GameSession.user_won), func.count()) |
|
I'm running into this issue as well. For me, and the OP, this appears to be caused by having "too many" arguments, where "too many" is > 4 since the select overload variants max out at 4 arguments. Looking at the implementation of select, I went with the following approach to get around the type checking issue: query: Select[tuple[ModelA, int, int, int, int]] = (
Select(
Model,
col(subquery.c.a), # These subquery columns are all from `func.count`
col(subquery.c.b),
col(subquery.c.c),
col(subquery.c.d),
).join(...)
r = session.exec(query).all() |
|
Commenting to chime in that doing what was suggested in related PR would help me with this issue. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
{{title}}
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
{{editor}}'s edit
{{editor}}'s edit
Uh oh!
There was an error while loading. Please reload this page.
First Check
Commit to Help
Example Code
Description
I'm selecting multiple model attributes and calculated attributes and there is a mypy error:
A long list of "Possible overload variants" follows.
PS.: There is no error when I from sqlalchemy import select. The mypy error only happens if I from sqlmodel import select. In the former case, however, sqlmodel.Session complains if I use it with sqlalchemy.select.
Operating System
Linux
Operating System Details
Docker image python:3.10.2-bullseye
SQLModel Version
0.0.6
Python Version
3.10
Additional Context