Repository navigation
ref(compat): Remove unused with_metaclass helper - #8153
Merged
Merged
Conversation
Co-Authored-By: Ivana Kellyer <ivana.kellyer@sentry.io>
sentrivana
approved these changes
Oct 29, 2026
Contributor
Coverage Results 📊✅ 57523 passed | ⏭️ 2979 skipped | Total: 60502 | Pass Rate: 95.08% | Execution Time: 154m 15s All tests are passing successfully. ✅ Patch coverage is 100.00% (no changed executable lines found; target 80%). Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## master #8153 +/-##
==========================================
- Coverage 90.32% 90.20% -0.12%
==========================================
Files 203 198 -5
Tracked lines 26872 21307 -5565
Branches 10044 7380 -2664
==========================================
- Hits 24272 19219 -5053
+ Misses 2600 2088 -512
+ Partials 1520 1239 -281Generated by Coverage Action |
sentrivana
added a commit
that referenced
this pull request
Oct 29, 2026
…8154) ### Description Removes the `PY37` flag from `sentry_sdk/_compat.py`, along with the code paths that only ran when it was `False`. It also removes the `nanosecond_time()` wrapper, which existed only to choose between those paths. `setup.py` sets `python_requires=">=3.7"`, so `PY37` is always `True` on every supported interpreter, and the `tox.ini` matrix starts at py3.7. That makes these branches unreachable: - `nanosecond_time()` in `sentry_sdk/utils.py`: the `int(time.perf_counter() * 1e9)` fallback is gone. Once only `time.perf_counter_ns()` was left, the wrapper added nothing, so it's removed as well. Its two call sites in `sentry_sdk/traces.py` (`Span` start and end) now call `time.perf_counter_ns()` directly. - `tests/test_gevent.py`: `compression_algo` always includes `"br"` now, as it already did in practice. - `tests/test_transport.py`: `elif PY37:` becomes `else:`, and the pre-3.7 case list after it is removed. The cases that run on 3.7 are unchanged. `PY38`, `PY310` and `PY311` are still used, so they stay. This doesn't depend on #8153; the two only touch different lines of `_compat.py` and merge cleanly together. `_compat` and `utils` are private modules, and nothing else in the repo (including tests) references `nanosecond_time`. Runtime behavior doesn't change on any supported Python version. #### Issues n/a <!-- junior-request-attribution:start --> via **Ivana Kellyer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0BTREZTS2Z%3A1793270559.842119 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0BTREZTS2Z%3A1793270559.842119) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0BTREZTS2Z%3A1793270559.842119/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
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
Removes
with_metaclass()fromsentry_sdk/_compat.py. Nothing onmajor/3.0uses it anymore.It's a Python 2 /
six-style helper for declaring a metaclass across Python versions; on Python 3 you just writeclass Foo(metaclass=Meta). Its only caller wasclass Hub(with_metaclass(HubMeta))insentry_sdk/hub.py. #6919 ("Drop hub related code in new major") deletedHuband the import, but left the helper behind.With the helper gone, the
TYPE_CHECKINGblock in_compat.py(Any,TypeVar,T) is unused too, so it's removed as well.Twasn't used before this change either.Evidence
major/3.0,git grep with_metaclassmatches only the definition. There are no callers insentry_sdk,tests,scriptsordocs.TorAnyfromsentry_sdk._compat.master) proposed the same removal as part of larger Python 2 cleanups. Both were closed without being merged, one for inactivity. Neither raised an objection to this change. Onmaster,Hubstill uses the helper, so this only applies tomajor/3.0._compatis a private module, so this doesn't touch the public API.Issues
n/a
via Ivana Kellyer.
--
View Junior Session [Sentry]