Motor-Types (stubs only)

raw JSON →
1.0.0b4 verified Fri May 01 auth: no python

Third-party PEP 561 type stubs for Motor, the async MongoDB driver for Tornado and AsyncIO. Current version 1.0.0b4 (pre-release). Alpha-level coverage; many symbols still untyped. Cadence: infrequent.

pip install motor-types
error Cannot find reference 'AsyncIOMotorClient' in '__init__.pyi'
cause motor-types stubs for some submodules may be incomplete or not installed correctly.
fix
Ensure motor-types is installed (pip install motor-types). If still failing, the stub might be missing; use # type: ignore or report.
error Import 'motor.motor_asyncio' could not be resolved
cause Motor itself is not installed; stubs alone do not make the package importable.
fix
Install motor: pip install motor. motor-types only provides type hints.
deprecated motor-types is in pre-release (beta). Do not use in production for type-checking; many stubs are incomplete or missing.
fix Pin to 1.0.0b4 and test coverage before relying on stubs. Expect frequent breaking changes.
gotcha motor-types provides stubs only. Do not import anything from it; always import from `motor.motor_asyncio` or `motor.motor_tornado`.
fix Use `from motor.motor_asyncio import AsyncIOMotorClient` as usual.
gotcha Stubs may not cover all Motor classes and methods. You may see 'cannot find reference' errors in your IDE for some functions.
fix Install the latest version; if missing, report to GitHub or add your own stubs.

Basic create, insert, query with Motor (quickstart for the driver, not stubs). motor-types provides the type hints.

import asyncio
from motor.motor_asyncio import AsyncIOMotorClient

async def main():
    client = AsyncIOMotorClient('mongodb://localhost:27017')
    db = client.test_database
    collection = db.test_collection
    await collection.insert_one({'x': 1})
    doc = await collection.find_one({'x': 1})
    print(doc)

asyncio.run(main())