Repository navigation
PYTHON-6230 Enable ruff rule UP041 to unify TimeoutErrors - #3185
Merged
Merged
Conversation
NoahStapp
requested review from
sleepyStick
and
a balanced review from Copilot
November 6, 2026 18:28
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the timeout-handling standardization and Ruff UP041 enablement.
No open issues 🎉
What changed in this PR
This PR enables Ruff’s UP041 rule and standardizes timeout handling on the built-in TimeoutError across PyMongo’s networking, encryption, and related tests.
Changes:
- Removes the
UP041suppression from Ruff configuration. - Replaces qualified timeout exceptions with
TimeoutErrorin driver code. - Updates test expectations and timeout-related comments.
| File | Description |
|---|---|
test/test_load_balancer.py |
Updates the generated wait helper’s timeout handler. |
test/test_kms_connect.py |
Updates KMS timeout assertions and simulated errors. |
test/asynchronous/test_locks.py |
Updates the condition-wait timeout assertion. |
test/asynchronous/test_load_balancer.py |
Updates the async wait helper’s timeout handler. |
test/asynchronous/test_async_network_layer.py |
Updates the blocking socket-call timeout assertion. |
pyproject.toml |
Enables Ruff’s UP041 rule. |
pymongo/synchronous/encryption.py |
Updates generated KMS timeout conversion and removes an unused import. |
pymongo/synchronous/_kms_connect.py |
Updates generated KMS connection timeout handling. |
pymongo/pyopenssl_context.py |
Uses built-in timeout exceptions for TLS operations. |
pymongo/pool_shared.py |
Standardizes connection timeout creation and classification. |
pymongo/network_layer.py |
Standardizes send/receive timeout handling and updates comments. |
pymongo/lock.py |
Updates the async condition-wait timeout handler. |
pymongo/asynchronous/encryption.py |
Updates KMS timeout conversion and removes an unused import. |
pymongo/asynchronous/_kms_connect.py |
Standardizes async KMS connection timeout handling. |
pymongo/_kms_connect_shared.py |
Standardizes proxy connection and deadline timeout handling. |
Review effort: Balanced
sleepyStick
approved these changes
Nov 9, 2026
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-6230
Changes in this PR
Remove suppression of ruff's
UP041rule to unifyTimeoutErrortypes.Test Plan
Checklist
Checklist for Author
Checklist for Reviewer