You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/examples/type_hints.rst
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,12 +92,14 @@ Note that when using :class:`~bson.son.SON`, the key and value types must be giv
92
92
Typed Collection
93
93
----------------
94
94
95
-
You can use :py:class:`~typing_extensions.TypedDict` (Python 3.8+) when using a well-defined schema for the data in a :class:`~pymongo.collection.Collection`.
96
-
Note that all `schema_validation`_ for inserts and updates is done on the server. This is due to the fact that these methods automatically add
97
-
an "_id" field. In the example below the "_id" field is marked by the :py:class:`~typing_extensions.NotRequired` notation to allow it to be accessed when reading
98
-
from `result`. If it is simply not included in the definition, then it will be automatically added, but it will raise a type-checking error if you attempt to access it.
99
-
Another option would be to generate the "_id" field yourself, and make it a required field. This would give the expected behavior, but would then also prevent you from
100
-
relying on PyMongo to insert the "_id" field.
95
+
You can use :py:class:`~typing_extensions.TypedDict` (Python 3.8+) when using a well-defined schema for the data in a
96
+
:class:`~pymongo.collection.Collection`. Note that all `schema validation`_ for inserts and updates is done on the server.
97
+
These methods automatically add an "_id" field. In the example below the "_id" field is
98
+
marked by the :py:class:`~typing_extensions.NotRequired` notation to allow it to be accessed when reading from
99
+
``result``. If it is simply not included in the definition, then it will be automatically added, but it will raise a
100
+
type-checking error if you attempt to access it. Another option would be to generate the "_id" field yourself, and make
101
+
it a required field. This would give the expected behavior, but would then also prevent you from relying on PyMongo to
0 commit comments