“AsyncIOMotorCollection” expects no type arguments, but 1 given
Pylance also gives a similar message. Did they remove it at some point? For some reason, I can’t find any mention of this on the internet. Apologies if this has been brought up before.
Here are my versions:
Python 3.9.21
pymongo 4.6.3
motor 3.4.0
Running mypy 1.15.0. It’s actually running inside a python:3.9.21-slim-bookworm docker container if that’s any help. Here’s the output for that file.
test.py:12: error: “AsyncIOMotorClient” expects no type arguments, but 1 given [type-arg]
test.py:13: error: “AsyncIOMotorDatabase” expects no type arguments, but 1 given [type-arg]
test.py:14: error: “AsyncIOMotorCursor” expects no type arguments, but 1 given [type-arg]
test.py:15: error: “AsyncIOMotorCollection” expects no type arguments, but 1 given [type-arg]
test.py:16: error: “AsyncIOMotorChangeStream” expects no type arguments, but 1 given [type-arg]
test.py:17: error: “AsyncIOMotorClientEncryption” expects no type arguments, but 1 given [type-arg]
Found 6 errors in 1 file (checked 1 source file)
Oh now I just feel silly. Seems all I needed was to just update pymongo and motor to the latest versions. The dockerfile I used had something to do with it as well. I would install the dependencies inside a non-slim python image and then copy over the venv folder to the slim python image. For whatever reason, that breaks in the older versions. I should note that those older versions did work as long as I didn’t do the venv copying.