Closed QSHolzner closed 7 months ago
Hi! Thank you for the catch. I'll check and fix it this/next week.
Hi @QSHolzner , Unfortunately, I can not reproduce it. Could you please provide you system version, beanie version and other nessasary details to me be able to reproduce correctly. I use Ubuntu 22.04, beanie 1.23.6
Hi Roman, sorry I think I missed some context in the description. There is no runtime error in this example. I get the type error in VSCode from the pylance plugin. Pylance uses pyright for type checking. If I start pyright from command-line I get the following message:
/workspaces/api-server/scripts/beanie_demo.py:26:45 - error: Argument of type "AgnosticClientSession" cannot be assigned to parameter "session" of type "ClientSession | None" in function "find_one" Type "AgnosticClientSession" cannot be assigned to type "ClientSession | None" "AgnosticClientSession" is incompatible with "ClientSession" "AgnosticClientSession" is incompatible with "None" (reportGeneralTypeIssues)
Used Versions: beanie==1.23.6 motor==3.3.2
Hope this helps. Thank you
This issue is stale because it has been open 30 days with no activity.
This issue was closed because it has been stalled for 14 days with no activity.
ClienSession type error Since the update to motor 3.3 I get type errors. In motor 3.3 additional type hints have been added to the public API. The type returned by
AsyncIOMotorClient
start_session()
isAsyncIOMotorClientSession
orAgnosticClientSession
. Thefind_one
function of beanieDocument
expects aClientSession
for thesession
parameter. I think the parameter type should be changed to AsyncIOMotorClientSession.The
AsyncIOMotorClientSession
is a Container for the encapsulated PyMongoClientSession
. When motor then executes Db actions theClientSession
contained in theAsyncIOMotorClientSession
is extracted and passed to PyMongo.I hope in the following example this becomes clear.
With the assignment
session=s
the following error message comes: An argument of type "AgnosticClientSession" cannot be assigned to the parameter "session" of type "ClientSession | None" in the function "find_one".