|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | """Operation class definitions.""" |
16 | | -from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Union |
| 16 | +from typing import Any, Dict, Generic, List, Mapping, Optional, Sequence, Tuple, Union |
17 | 17 |
|
| 18 | +from bson.raw_bson import RawBSONDocument |
18 | 19 | from pymongo import helpers |
19 | 20 | from pymongo.collation import validate_collation_or_none |
20 | 21 | from pymongo.common import validate_boolean, validate_is_mapping, validate_list |
21 | 22 | from pymongo.helpers import _gen_index_name, _index_document, _index_list |
22 | | -from pymongo.typings import _CollationIn, _DocumentIn, _Pipeline |
| 23 | +from pymongo.typings import _CollationIn, _DocumentType, _Pipeline |
23 | 24 |
|
24 | 25 |
|
25 | | -class InsertOne(object): |
| 26 | +class InsertOne(Generic[_DocumentType]): |
26 | 27 | """Represents an insert_one operation.""" |
27 | 28 |
|
28 | 29 | __slots__ = ("_doc",) |
29 | 30 |
|
30 | | - def __init__(self, document: _DocumentIn) -> None: |
| 31 | + def __init__(self, document: Union[_DocumentType, RawBSONDocument]) -> None: |
31 | 32 | """Create an InsertOne instance. |
32 | 33 |
|
33 | 34 | For use with :meth:`~pymongo.collection.Collection.bulk_write`. |
@@ -170,15 +171,15 @@ def __ne__(self, other: Any) -> bool: |
170 | 171 | return not self == other |
171 | 172 |
|
172 | 173 |
|
173 | | -class ReplaceOne(object): |
| 174 | +class ReplaceOne(Generic[_DocumentType]): |
174 | 175 | """Represents a replace_one operation.""" |
175 | 176 |
|
176 | 177 | __slots__ = ("_filter", "_doc", "_upsert", "_collation", "_hint") |
177 | 178 |
|
178 | 179 | def __init__( |
179 | 180 | self, |
180 | 181 | filter: Mapping[str, Any], |
181 | | - replacement: Mapping[str, Any], |
| 182 | + replacement: Union[_DocumentType, RawBSONDocument], |
182 | 183 | upsert: bool = False, |
183 | 184 | collation: Optional[_CollationIn] = None, |
184 | 185 | hint: Optional[_IndexKeyHint] = None, |
|
0 commit comments