ref: Remove contextvars compatibility code in new major - #6918
Open
sentrivana wants to merge 7 commits into
Open
ref: Remove contextvars compatibility code in new major#6918sentrivana wants to merge 7 commits into
sentrivana wants to merge 7 commits into
Conversation
Drop the contextvars compatibility layer that supported Python 3.6 (aiocontextvars), old gevent (<20.9.0), and old greenlet (<0.5). - Remove `_is_contextvars_broken`, `_make_threadlocal_contextvars`, `_get_contextvars`, `HAS_REAL_CONTEXTVARS`, and `CONTEXTVARS_ERROR_MESSAGE` from utils.py - Use `from contextvars import ContextVar` directly everywhere - Remove `unsafe_context_data` parameter from `SentryAsgiMiddleware` - Remove contextvars checks from aiohttp, asgi, tornado, sanic, and django integrations - Add version deprecation warnings for gevent <20.9.0 and greenlet <0.5 in `_check_version_deprecations()` - Add type annotations to all ContextVar declarations
Contributor
Codecov Results 📊✅ 96014 passed | ⏭️ 6397 skipped | Total: 102411 | Pass Rate: 93.75% | Execution Time: 340m 47s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 94.87%. Project has 2486 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 89.83% 89.72% -0.11%
==========================================
Files 193 192 -1
Lines 24588 24190 -398
Branches 8744 8600 -144
==========================================
+ Hits 22089 21704 -385
- Misses 2499 2486 -13
- Partials 1400 1395 -5Generated by Codecov Action |
sentrivana
marked this pull request as ready for review
July 29, 2026 11:25
alexander-alderman-webb
approved these changes
Jul 29, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7d7ac53. Configure here.
ericapisani
approved these changes
Jul 29, 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.

Description
Drop the contextvars compatibility layer that supported Python 3.6 (aiocontextvars), old gevent (<20.9.0), and old greenlet (<0.5).
Warn if using an older version of either during setup.
This allows us to remove the whole machinery around checking whether contextvars are safe to use and replacing them if not.
Note: 3.6 tests are expected to fail on this. They'll be dropped in #6904
Issues
Closes #5037
Reminders
uv run ruff.feat:,fix:,ref:,meta:)