Skip to content

PYTHON-5917 Fix document_class generic alias check on PyPy#2917

Draft
blink1073 wants to merge 1 commit into
mongodb:masterfrom
blink1073:PYTHON-5917
Draft

PYTHON-5917 Fix document_class generic alias check on PyPy#2917
blink1073 wants to merge 1 commit into
mongodb:masterfrom
blink1073:PYTHON-5917

Conversation

@blink1073

Copy link
Copy Markdown
Member

PYTHON-5917

Changes in this PR

Fixes a PyPy-only failure when validating a parameterized generic document_class (e.g. dict[str, Any], SON[str, Any]).

Passing build: https://spruce.corp.mongodb.com/version/6a4bd47a30181800078c2ed7/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC

Test Plan

Covered by existing unit tests exercising generic document_class values; verified passing on PyPy via the Evergreen patch linked above.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

issubclass() does not raise TypeError for generic aliases like
dict[str, Any] or SON[str, Any] on all Python implementations (e.g.
PyPy), so the exception-based fallback to check __origin__ never ran,
causing a spurious TypeError. Resolve __origin__ before the subclass
check instead of relying on catching the error.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bson/codec_options.py 66.66% 1 Missing ⚠️
pymongo/common.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants