Skip to content

Commit d06a639

Browse files
ameilybehackett
authored andcommitted
Addressed comments in PR: changed insert_many() to accept any iterable.
1 parent 1e5c897 commit d06a639

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pymongo/collection.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import collections
1818
import warnings
19-
from types import GeneratorType
2019

2120
from bson.code import Code
2221
from bson.objectid import ObjectId
@@ -469,7 +468,7 @@ def insert_one(self, document):
469468
self.write_concern.acknowledged)
470469

471470
def insert_many(self, documents, ordered=True):
472-
"""Insert a list or generator of documents.
471+
"""Insert an iterable of documents.
473472
474473
>>> db.test.count()
475474
0
@@ -480,7 +479,7 @@ def insert_many(self, documents, ordered=True):
480479
2
481480
482481
:Parameters:
483-
- `documents`: A list or generator of documents to insert.
482+
- `documents`: A iterable of documents to insert.
484483
- `ordered` (optional): If ``True`` (the default) documents will be
485484
inserted on the server serially, in the order provided. If an error
486485
occurs all remaining inserts are aborted. If ``False``, documents
@@ -492,7 +491,7 @@ def insert_many(self, documents, ordered=True):
492491
493492
.. versionadded:: 3.0
494493
"""
495-
if not isinstance(documents, (list, GeneratorType)) or not documents:
494+
if not isinstance(documents, collections.Iterable) or not documents:
496495
raise TypeError("documents must be a non-empty list")
497496
inserted_ids = []
498497
def gen():

0 commit comments

Comments
 (0)