Skip to content

ref(compat): Remove always-true PY37 flag and nanosecond_time helper - #8154

Merged
sentrivana merged 2 commits into
major/3.0from
ivana/remove-py37-flag
Oct 29, 2026
Merged

sentrivana merged 2 commits into
major/3.0from
ivana/remove-py37-flag

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

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

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:44
Co-Authored-By: Ivana Kellyer <ivana.kellyer@sentry.io>
@sentry-junior sentry-junior Bot changed the title ref(compat): Remove always-true PY37 flag ref(compat): Remove always-true PY37 flag and nanosecond_time helper Oct 29, 2026
@sentrivana
sentrivana merged commit 3668ba4 into major/3.0 Oct 29, 2026
149 checks passed
@sentrivana
sentrivana deleted the ivana/remove-py37-flag branch October 29, 2026 11:54
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 57523 passed | ⏭️ 2979 skipped | Total: 60502 | Pass Rate: 95.08% | Execution Time: 160m 60s

All tests are passing successfully.

✅ Patch coverage is 100.00% (3 of 3 changed executable lines covered; target 80%).
Project statement coverage is 90.20% (down 0.13 percentage points from base (20df0da) to head (3525c0d)).

Changed files with executable lines (1)
File Patch coverage Changed executable lines
sentry_sdk/traces.py 100.00% 3/3 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8154       +/-##
==========================================
- Coverage    90.33%    90.20%    -0.13%
==========================================
  Files          203       198        -5
  Tracked lines     26872     21307     -5565
  Branches     10044      7378     -2666
==========================================
- Hits         24272     19218     -5054
+ Misses        2600      2089      -511
+ Partials      1520      1237      -283

Generated by Coverage Action

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