-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4903 Adds typing overloading to bson.binary.Binary.from_vector #1967
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-4903 Adds typing overloading to bson.binary.Binary.from_vector #1967
Conversation
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.
We should also remove the BETA and add a changelog entry
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.
Do we have a test that from_vector(BinaryVector(), dtype=...)
raises an error and requires a type-ignore?
test/test_bson.py
Outdated
@@ -802,6 +802,13 @@ def test_vector(self): | |||
assert float_binary == Binary.from_vector( | |||
BinaryVector(list_vector, BinaryVectorDtype.FLOAT32) | |||
) | |||
# Confirm kwargs cannot be passed when BinaryVector is provided | |||
self.assertRaises( |
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.
Can you write this as a with self.assertRaises():
so we can confirm a "type-ignore" is detected?
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.
Sure can. How do we confirm that a type-ignore is detected?
with self.assertRaises(ValueError):
Binary.from_vector(
BinaryVector(list_vector, BinaryVectorDtype.PACKED_BIT, padding),
dtype=BinaryVectorDtype.PACKED_BIT
)
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.
Oh.... I see. This will fail linting without it.
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.
Yep that's what I was thinking!
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.
TIL. Thanks @ShaneHarvey ! This was a very cool lesson.
… incorrect signature with [call-overload]
Follows suggestion from @ShaneHarvey that adding typing oveloading would make clear that dtype is a required argument when the first argument, vector, is a list, not at BinaryVector instance.