Motor 3.3.0 Released

We are pleased to announce the 3.3.0 release of Motor - MongoDB’s Asynchronous Python Driver. This release brings support for PyMongo 4.5 and Python 3.12.

See the changelog for a high-level summary of what is in this release or see the Motor 3.3.0 release notes in JIRA for the complete list of resolved issues.

Documentation: Motor: Asynchronous Python driver for MongoDB — Motor 3.3.0 documentation

Changelog: Changelog — Motor 3.3.0 documentation

Source: GitHub - mongodb/motor at 3.3.0

Thank you to everyone who contributed to this release!

Is there any documentation on how to use the type hints? This fails:

def mongo_client() -> AsyncIOMotorClient:  # <- Variable "motor.motor_asyncio.AsyncIOMotorClient" is not valid as a type  [valid-type]mypy(error)
    return AsyncIOMotorClient(os.environ["MONGO_URI"])

I can type it as a motor.core.AgnosticClient, but that just leads to other type errors.

2 Likes

I more or less figured it out. From what I can tell AgnosticCursor.to_list() is not fully typed, and also AgnosticConnection.find_one() typing fails for me with mypy 1.5.1.

Some documentation here would be nice, because I had to dig through code to figure this out.

1 Like

Thanks for the feedback @Mark_Edwards, I’ve opened https://jira.mongodb.org/browse/MOTOR-1177.

Hi,

Upgrading motor from 3.2.0 to 3.3.0 causes our process to crash with following error stack

  File "/home/insiderinternal/.local/lib/python3.11/site-packages/motor/motor_asyncio.py", line 53, in <module>
    AsyncIOMotorCollection = create_asyncio_class(core.AgnosticCollection)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/insiderinternal/.local/lib/python3.11/site-packages/motor/motor_asyncio.py", line 41, in create_asyncio_class
    return create_class_with_framework(cls, asyncio_framework, "motor.motor_asyncio")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/insiderinternal/.local/lib/python3.11/site-packages/motor/metaprogramming.py", line 289, in create_class_with_framework
    new_class_attr = attr.create_attribute(new_class, name)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/insiderinternal/.local/lib/python3.11/site-packages/motor/metaprogramming.py", line 153, in create_attribute
    method = getattr(cls.__delegate_class__, name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Collection' has no attribute 'create_search_index'

We are using mongodb 6.0.3, and motor as python’s asynchronous library interface.

Hi @Shashank_Nigam, it looks like your upgrade didn’t pick up the new requirement of pymongo>=4.5,<5. What command(s) did you use to upgrade? In the mean time, you can install the latest pymongo manually as pip install --upgrade pymongo.

Thanks for pointing that out. After updating pymongo, library works fine

This topic was automatically closed after 90 days. New replies are no longer allowed.