You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importasyncioimportasyncpgasyncdefmain() ->int:
connection_string="postgresql://postgres:[email protected]:5432/postgres"conn=awaitasyncpg.connect(connection_string)
result=awaitconn.fetch("SELECT 1 + 1 AS num", record_class=Row)
row=result[0]
num=row["num"]
print(type(num))
returnnum# mypy error: Returning Any from function declared to return "int"classRow(asyncpg.Record):
num: intif__name__=="__main__":
asyncio.run(main())
In essence, the type of num is Any instead of int. I tried to make Row inherit from TypedDict or use a dataclass, both failed.
I'll also be happy to help develop this feature with some general guidance.
The text was updated successfully, but these errors were encountered:
Consider the following:
In essence, the type of
num
isAny
instead ofint
. I tried to makeRow
inherit fromTypedDict
or use adataclass
, both failed.I'll also be happy to help develop this feature with some general guidance.
The text was updated successfully, but these errors were encountered: