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
PYTHON-3493 Bulk Write InsertOne Should Be Parameter Of Collection Type #1106
Changes from all commits
2a9f80b
7292fbe
39b32b2
c9b67ac
032271e
cf8f8b0
3d0ae16
1a9e5d7
46cc1c7
dd44e38
c16532e
9c26531
c3b1226
fbb7862
be764e5
a8afc6a
e1938c4
c205357
a0ece18
62f4918
6d12caa
0d4f9bd
b68ed1b
b0b7a81
6328f59
65d18bf
99e20a7
f153b45
371b474
71f9370
be4c899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,7 +296,7 @@ def test_upsert(self): | |
def test_numerous_inserts(self): | ||
# Ensure we don't exceed server's maxWriteBatchSize size limit. | ||
n_docs = client_context.max_write_batch_size + 100 | ||
requests = [InsertOne({}) for _ in range(n_docs)] | ||
requests = [InsertOne[dict]({}) for _ in range(n_docs)] | ||
result = self.coll.bulk_write(requests, ordered=False) | ||
self.assertEqual(n_docs, result.inserted_count) | ||
self.assertEqual(n_docs, self.coll.count_documents({})) | ||
|
@@ -347,7 +347,7 @@ def test_bulk_write_no_results(self): | |
|
||
def test_bulk_write_invalid_arguments(self): | ||
# The requests argument must be a list. | ||
generator = (InsertOne({}) for _ in range(10)) | ||
generator = (InsertOne[dict]({}) for _ in range(10)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these changes required? This seems annoyingly verbose for users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required because otherwise mypy complains:
I'm not sure why it doesn't resolve to the bound of the TypeVar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the same reason we need a type annotation on MongoClient There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, it's just empty/untyped dictionary. A non-empty dict works without a manual type annotation:
It's a shame the error message is so opaque. |
||
with self.assertRaises(TypeError): | ||
self.coll.bulk_write(generator) # type: ignore[arg-type] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs the python version guard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of, please schedule the docs and doctest evergreen tasks when changing things like this.