Skip to content

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

Merged
merged 3 commits into from
Aug 10, 2023

Conversation

sleepyStick
Copy link
Contributor

Verified

This commit was signed with the committer’s verified signature.
avedmala Abhinav Vedmala
@sleepyStick sleepyStick marked this pull request as ready for review August 10, 2023 19:28
@sleepyStick sleepyStick requested a review from a team as a code owner August 10, 2023 19:28
@sleepyStick sleepyStick requested review from NoahStapp and removed request for a team August 10, 2023 19:28
@@ -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
Copy link
Member

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.

Copy link
Contributor Author

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)

Copy link
Member

@ShaneHarvey ShaneHarvey left a 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?

Verified

This commit was signed with the committer’s verified signature.
avedmala Abhinav Vedmala
@sleepyStick
Copy link
Contributor Author

Yes! Just wrote some tests! :)

Verified

This commit was signed with the committer’s verified signature.
avedmala Abhinav Vedmala
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sleepyStick sleepyStick merged commit 0d44783 into mongodb:master Aug 10, 2023
@sleepyStick sleepyStick deleted the PYTHON-3821 branch August 10, 2023 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants