Repository navigation
PYTHON-6236 Enable ruff rule B905 for clearer zip() calls - #3190
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change enabling Ruff B905 and making zip() length handling explicit.
No open issues 🎉
What changed in this PR
Enables Ruff rule B905 across PyMongo, making each changed zip() call explicit about whether unequal input lengths are allowed.
Changes:
- Removes the B905 lint exemption.
- Adds
strict=Truewhere paired inputs should have equal lengths. - Uses
strict=Falseto preserve truncation behavior in selected test helpers and cursor tests, with corresponding generated synchronous updates.
| File | Description |
|---|---|
test/unified_format.py |
Mirrors strict error and log comparisons. |
test/unified_format_shared.py |
Preserves non-strict sequence matching. |
test/test_uri_spec.py |
Requires equal host-list lengths. |
test/test_read_preferences.py |
Mirrors strict latency-to-host pairing. |
test/test_raw_bson_shared.py |
Requires equal key-order comparison lengths. |
test/test_monitoring.py |
Mirrors strict command-event pairing. |
test/test_heartbeat_monitoring.py |
Mirrors non-strict heartbeat comparisons. |
test/test_encryption.py |
Mirrors strict result and key pairing. |
test/test_custom_types.py |
Mirrors strict BSON decoding comparisons. |
test/test_cursor.py |
Mirrors non-strict counter-to-cursor pairing. |
test/test_connection_monitoring.py |
Mirrors non-strict connection-event comparisons. |
test/test_client.py |
Mirrors strict database-result comparisons. |
test/test_change_stream.py |
Mirrors strict list comparisons. |
test/test_bulk.py |
Mirrors strict bulk-response comparisons. |
test/asynchronous/unified_format.py |
Requires equal error and log comparison lengths. |
test/asynchronous/test_read_preferences.py |
Requires equal latency and host counts. |
test/asynchronous/test_monitoring.py |
Requires equal started and succeeded event counts. |
test/asynchronous/test_heartbeat_monitoring.py |
Preserves non-strict heartbeat comparisons. |
test/asynchronous/test_encryption.py |
Requires equal result and key pairing lengths. |
test/asynchronous/test_custom_types.py |
Requires decoded document counts to match expectations. |
test/asynchronous/test_cursor.py |
Allows finite cursors to pair with infinite counters. |
test/asynchronous/test_connection_monitoring.py |
Preserves non-strict connection-event comparisons. |
test/asynchronous/test_client.py |
Requires equal database-result lengths. |
test/asynchronous/test_change_stream.py |
Requires equal list comparison lengths. |
test/asynchronous/test_bulk.py |
Requires equal bulk-response comparison lengths. |
pyproject.toml |
Enables B905 by removing its exemption. |
pymongo/pool_options.py |
Requires equal metadata name and version segment counts. |
pymongo/message.py |
Requires equal operation and namespace counts. |
pymongo/auth_shared.py |
Requires equal byte-string lengths for XOR. |
.evergreen/scripts/generate_config_utils.py |
Requires equal host configuration list lengths. |
Review effort: Balanced
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PYTHON-6236
Changes in this PR
Enable ruff rule B905 for clearer zip() calls.
Test Plan
Existing test suite.
Checklist
Checklist for Author
[ ] Did you update the changelog (if necessary)?[ ] Is any followup work tracked in a JIRA ticket? If so, add link(s).Checklist for Reviewer