Repository navigation
PYTHON-6227 Enable ruff rule UP035 to remove deprecated import aliases - #3182
Merged
Merged
Conversation
NoahStapp
requested review from
sleepyStick
and
a balanced review from Copilot
November 6, 2026 15:35
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the deprecated typing-import cleanup and Ruff rule update.
No open issues 🎉
What changed in this PR
This PR enables Ruff’s UP035 rule and modernizes deprecated typing imports across PyMongo, BSON, and the test suite.
Changes:
- Removes
UP035from Ruff’s ignored rules. - Replaces
typing.Callablewithcollections.abc.Callable, including generated synchronous counterparts. - Changes the typing test’s
NotRequiredimport to usetyping.
| File | Description |
|---|---|
test/test_typing.py |
Updates Callable and NotRequired imports. |
test/test_session.py |
Updates the generated session test’s Callable import. |
test/asynchronous/test_session.py |
Modernizes the session test’s Callable import. |
test/asynchronous/__init__.py |
Modernizes test infrastructure’s Callable import. |
test/__init__.py |
Updates the synchronous test infrastructure’s import. |
pyproject.toml |
Enables Ruff’s deprecated-import rule. |
pymongo/topology_shared.py |
Modernizes the shared topology’s Callable import. |
pymongo/topology_description.py |
Modernizes the topology description’s Callable import. |
pymongo/synchronous/uri_parser.py |
Updates the generated URI parser’s import. |
pymongo/synchronous/topology.py |
Updates the generated topology’s import. |
pymongo/synchronous/srv_resolver.py |
Updates the generated SRV resolver’s import. |
pymongo/synchronous/settings.py |
Updates the generated settings’ import. |
pymongo/synchronous/mongo_client.py |
Updates the generated client’s import. |
pymongo/synchronous/helpers.py |
Updates generated helpers’ import. |
pymongo/synchronous/command_runner.py |
Updates the generated command runner’s import. |
pymongo/synchronous/collection.py |
Updates the generated collection’s import. |
pymongo/synchronous/client_session.py |
Updates the generated client session’s import. |
pymongo/synchronous/auth.py |
Updates generated authentication’s import. |
pymongo/settings_shared.py |
Modernizes shared settings’ Callable import. |
pymongo/pyopenssl_context.py |
Modernizes the TLS context’s Callable import. |
pymongo/network_layer.py |
Modernizes the network layer’s Callable import. |
pymongo/mongo_client_shared.py |
Modernizes shared client code’s Callable import. |
pymongo/message.py |
Modernizes message handling’s Callable import. |
pymongo/encryption_options.py |
Modernizes encryption options’ Callable import. |
pymongo/common.py |
Modernizes common utilities’ Callable import. |
pymongo/client_session_shared.py |
Modernizes shared session code’s Callable import. |
pymongo/auth_shared.py |
Modernizes shared authentication’s Callable import. |
pymongo/auth_oidc_shared.py |
Modernizes OIDC authentication’s Callable import. |
pymongo/asynchronous/uri_parser.py |
Modernizes the URI parser’s Callable import. |
pymongo/asynchronous/topology.py |
Modernizes the topology’s Callable import. |
pymongo/asynchronous/srv_resolver.py |
Modernizes the SRV resolver’s Callable import. |
pymongo/asynchronous/settings.py |
Modernizes settings’ Callable import. |
pymongo/asynchronous/mongo_client.py |
Modernizes the client’s Callable import. |
pymongo/asynchronous/helpers.py |
Modernizes helpers’ Callable import. |
pymongo/asynchronous/command_runner.py |
Modernizes the command runner’s Callable import. |
pymongo/asynchronous/collection.py |
Modernizes the collection’s Callable import. |
pymongo/asynchronous/client_session.py |
Modernizes the client session’s Callable import. |
pymongo/asynchronous/auth.py |
Modernizes authentication’s Callable import. |
pymongo/_kms_connect_shared.py |
Modernizes KMS connection code’s Callable import. |
pymongo/_csot.py |
Modernizes timeout utilities’ Callable import. |
bson/json_util.py |
Modernizes JSON utilities’ Callable import. |
bson/codec_options.py |
Modernizes codec options’ Callable import. |
bson/__init__.py |
Modernizes BSON’s Callable import. |
Review effort: Balanced
sleepyStick
approved these changes
Nov 6, 2026
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-6227
Changes in this PR
Remove suppression of ruff's UP035 rule.
Test Plan
Checklist
Checklist for Author
Checklist for Reviewer