-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3821 use overload pattern for _DocumentType #1352
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
Conversation
@@ -1131,11 +1143,13 @@ def decode_all( | |||
Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with | |||
`codec_options`. | |||
""" | |||
opts = codec_options or DEFAULT_CODEC_OPTIONS |
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.
What was wrong (according to mypy) with this code? I find the new code less readable since it calls _decode_all in multiple places.
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.
I was getting the following mypy error:
typecheck-mypy: commands[0]> mypy --install-types --non-interactive bson gridfs tools pymongo
bson/__init__.py: note: In function "decode_all":
bson/__init__.py:1150: error: Cannot infer type argument 1 of "_decode_all" [misc]
return _decode_all(data, opts)
^~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 85 source files)
typecheck-mypy: exit 1 (2.96 seconds) /Users/iris.ho/GitHub/mongo-python-driver> mypy --install-types --non-interactive bson gridfs tools pymongo pid=40888
.pkg: _exit> python /Users/iris.ho/Library/Python/3.9/lib/python/site-packages/pyproject_api/_backend.py True setuptools.build_meta
typecheck-mypy: FAIL code 1 (10.28=setup[7.32]+cmd[2.96] seconds)
evaluation failed :( (10.35 seconds)
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.
Is it possible to add tests for this change in test_typing.py to show that it improves the behavior?
Yes! Just wrote some tests! :) |
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.
Nice!
https://jira.mongodb.org/browse/PYTHON-3821