Skip to content

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

Merged
blink1073 merged 1 commit into
mongodb:masterfrom
blink1073:PYTHON-5917
Jul 7, 2026
Merged

blink1073 merged 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!

@blink1073
blink1073 marked this pull request as ready for review July 7, 2026 14:00
@blink1073
blink1073 requested a review from a team as a code owner July 7, 2026 14:00
@blink1073
blink1073 requested review from aclark4life and Copilot and removed request for Copilot July 7, 2026 14:00

@aclark4life aclark4life left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@blink1073
blink1073 merged commit a167a86 into mongodb:master Jul 7, 2026
101 of 102 checks passed
@blink1073
blink1073 deleted the PYTHON-5917 branch July 7, 2026 14:20
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.

3 participants