Skip to content

PYTHON-6236 Enable ruff rule B905 for clearer zip() calls - #3190

Merged
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6236
Nov 9, 2026
Merged

NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6236

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

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 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?

@NoahStapp
NoahStapp requested a review from a team as a code owner November 9, 2026 18:28
@NoahStapp
NoahStapp requested review from blink1073 and a balanced review from Copilot November 9, 2026 18:28

Copilot AI 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.

🟢 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=True where paired inputs should have equal lengths.
  • Uses strict=False to 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

@blink1073 blink1073 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@NoahStapp
NoahStapp merged commit 16d94e2 into mongodb:main Nov 9, 2026
67 of 73 checks passed
@NoahStapp NoahStapp mentioned this pull request Nov 9, 2026
6 tasks
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