Repository navigation
PYTHON-6158 Clean up version-gated code paths - #3112
aclark4life merged 2 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The removed branches only support now-unsupported Python versions, and the replacements preserve existing Python 3.11+ behavior.
0 open findings
What changed in this PR
Removes obsolete compatibility paths after raising the minimum supported Python version to 3.11.
Changes:
- Replaces the custom task wrapper with
asyncio.create_task. - Removes dead version checks and compatibility fallbacks.
- Enables Python 3.11+ test paths unconditionally.
| File | Description |
|---|---|
pymongo/_asyncio_task.py |
Removes the obsolete task compatibility module. |
pymongo/asynchronous/helpers.py |
Uses built-in anext and aiter. |
pymongo/synchronous/helpers.py |
Uses built-in next and iter. |
pymongo/cursor_shared.py |
Imports Self directly from typing. |
pymongo/network_layer.py |
Uses asyncio.create_task directly. |
pymongo/periodic_executor.py |
Uses asyncio.create_task directly. |
pymongo/pool_options.py |
Uses strict zip unconditionally. |
pymongo/pool_shared.py |
Removes the TLS injection version gate. |
test/helpers.py |
Updates generated task creation. |
test/asynchronous/helpers.py |
Updates asynchronous task creation. |
test/test_client.py |
Removes obsolete context-manager gating. |
test/asynchronous/test_client.py |
Removes obsolete async context-manager gating. |
test/test_discovery_and_monitoring.py |
Removes the obsolete barrier skip. |
test/asynchronous/test_discovery_and_monitoring.py |
Removes the obsolete barrier skip. |
test/test_encryption.py |
Accepts the modern TLS EOF error unconditionally. |
test/asynchronous/test_encryption.py |
Accepts the modern TLS EOF error unconditionally. |
test/asynchronous/test_locks.py |
Enables Python 3.11 asyncio tests unconditionally. |
test/test_retryable_writes.py |
Uses asyncio.create_task directly. |
test/asynchronous/test_retryable_writes.py |
Uses asyncio.create_task directly. |
test/test_ssl.py |
Removes obsolete async TLS test gates. |
test/asynchronous/test_ssl.py |
Removes obsolete async TLS test gates. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| # This error might be: | ||
| # EOF occurred in violation of protocol (_ssl.c:2384) |
There was a problem hiding this comment.
nit: can this be put onto the same line? or like can we fix the spacing here?
| @@ -67,7 +66,7 @@ def open(self) -> None: | |||
| if self._task is None or ( | |||
| self._task.done() and not self._task.cancelled() and not self._task.cancelling() # type: ignore[unused-ignore, attr-defined] | |||
There was a problem hiding this comment.
i could be wrong, but i think these type ignores can be removed here? (and on line 101)
- Remove obsolete type: ignore comments in periodic_executor.py - Merge cert_error EOF pattern onto one line in test_encryption.py
PYTHON-6158
Changes in this PR
Follow-up to PYTHON-6138 (drop Python 3.9 and 3.10). Removes version-gated code paths that are now dead on Python 3.11+:
pymongo/_asyncio_task.py, callers useasyncio.create_task.Selffromtypingunconditionally inpymongo/cursor_shared.py.pymongo/pool_shared.py.zip(..., strict=True)unconditionally inpymongo/pool_options.py.anext/aiterfallbacks inpymongo/asynchronous/helpers.py.Test Plan
Checklist
Checklist for Author
Checklist for Reviewer