Skip to content

DOCSP-48306 - Fix type hints #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ daemon in the global application group:
and in the `Multiple Python Sub Interpreters <https://modwsgi.readthedocs.io/en/master/user-guides/application-issues.html#multiple-python-sub-interpreters>`__
section of the mod_wsgi documentation.

.. _pymongo-tools-type-checkers:

Type Checkers
-------------

Expand Down
31 changes: 0 additions & 31 deletions source/write/bulk-write.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,37 +553,6 @@ The ``MongoClient.bulk_write()`` method returns a ``ClientBulkWriteResult`` obje
* - ``upserted_count``
- | The number of documents upserted, if any.

Type Hints
----------

.. include:: /includes/type-hints/intro.rst

When you use the ``bulk_write()`` method to perform an ``InsertOne`` or ``ReplaceOne``
operation,
The following code example shows how to insert
- ``~pymongo.collection.Collection.bulk_write()``

For ``bulk_write()``, both the ``~pymongo.operations.InsertOne()`` and
``~pymongo.operations.ReplaceOne()`` operators are generic.

The following code example shows that the results are the same as the preceding examples
when you call the ``bulk_write()`` method:

.. code-block:: python

from typing import TypedDict
from pymongo import MongoClient
from pymongo.operations import InsertOne
from pymongo.collection import Collection
client: MongoClient = MongoClient()
collection: Collection[Movie] = client.test.test
inserted = collection.bulk_write([InsertOne(Movie(name="Jurassic Park", year=1993))])
result = collection.find_one({"name": "Jurassic Park"})
assert result is not None
assert result["year"] == 1993

.. include:: /includes/type-hints/tip-more-info.rst

Troubleshooting
---------------

Expand Down
Loading