Skip to content

ref(compat): Remove unused with_metaclass helper - #8153

Merged
sentrivana merged 1 commit into
major/3.0from
ivana/remove-with-metaclass
Oct 29, 2026
Merged

sentrivana merged 1 commit into
major/3.0from
ivana/remove-with-metaclass

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Description

Removes with_metaclass() from sentry_sdk/_compat.py. Nothing on major/3.0 uses it anymore.

It's a Python 2 / six-style helper for declaring a metaclass across Python versions; on Python 3 you just write class Foo(metaclass=Meta). Its only caller was class Hub(with_metaclass(HubMeta)) in sentry_sdk/hub.py. #6919 ("Drop hub related code in new major") deleted Hub and the import, but left the helper behind.

With the helper gone, the TYPE_CHECKING block in _compat.py (Any, TypeVar, T) is unused too, so it's removed as well. T wasn't used before this change either.

Evidence

_compat is a private module, so this doesn't touch the public API.

Issues

n/a

via Ivana Kellyer.

--

View Junior Session [Sentry]

Co-Authored-By: Ivana Kellyer <ivana.kellyer@sentry.io>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner October 29, 2026 11:40
@github-actions

Copy link
Copy Markdown
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%).
Project statement coverage is 90.20% (down 0.12 percentage points from base (20df0da) to head (2476dbd)).

Files with missing lines (1)
File Coverage % Lines
sentry_sdk/_compat.py 93.94% ⚠️ 2 Missing
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      -281

Generated by Coverage Action

@sentrivana
sentrivana merged commit 9325cca into major/3.0 Oct 29, 2026
153 checks passed
@sentrivana
sentrivana deleted the ivana/remove-with-metaclass branch October 29, 2026 11:49
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>
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.

1 participant