Skip to content

PYTHON-6230 Enable ruff rule UP041 to unify TimeoutErrors - #3185

Merged
NoahStapp merged 2 commits into
mongodb:mainfrom
NoahStapp:PYTHON-6230
Nov 9, 2026
Merged

NoahStapp merged 2 commits into
mongodb:mainfrom
NoahStapp:PYTHON-6230

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

PYTHON-6230

Changes in this PR

Remove suppression of ruff's UP041 rule to unify TimeoutError types.

Test Plan

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 6, 2026 18:28
@NoahStapp
NoahStapp requested review from sleepyStick and a balanced review from Copilot November 6, 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 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 UP041 suppression from Ruff configuration.
  • Replaces qualified timeout exceptions with TimeoutError in 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

@NoahStapp
NoahStapp merged commit bc683fc into mongodb:main Nov 9, 2026
80 of 82 checks passed
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