Skip to content

ref(utils): Remove unused to_timestamp helper and epoch constant - #8147

Merged
sentrivana merged 1 commit into
masterfrom
ref/remove-unused-to-timestamp
Oct 29, 2026
Merged

sentrivana merged 1 commit into
masterfrom
ref/remove-unused-to-timestamp

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Description

Removes to_timestamp() and the module-level epoch constant from sentry_sdk/utils.py. Nothing uses either of them.

#4899 (removing the old metrics code) deleted the last three callers of to_timestamp, all in sentry_sdk/metrics.py, plus its import there. epoch was only ever used inside to_timestamp.

Evidence

  • grep -rnw to_timestamp sentry_sdk tests scripts only matches the definition.
  • grep -rnw epoch sentry_sdk tests only matches the definition and its use in to_timestamp. The other match is the (?P<epoch>...) regex group in the version parser, which isn't related.
  • git log -S "to_timestamp(" -- sentry_sdk tests shows chore: Remove old metrics code #4899 as the last change to touch a call site.
  • No open PR diff in this repo mentions to_timestamp or epoch.

Why it's safe

  • sentry_sdk.utils is an internal module. Neither name is re-exported from sentry_sdk or listed in docs/, and neither appears in CHANGELOG.md or MIGRATION_GUIDE.md.
  • The helper had a latent bug: it subtracted from a naive datetime(1970, 1, 1), so passing it a timezone-aware datetime (the SDK uses aware UTC datetimes everywhere) raised TypeError. Leaving it around invites someone to reuse it by mistake.
  • datetime is still imported and used elsewhere in the module.
  • No runtime behavior changes.

Checks

  • uv run ruff check sentry_sdk tests and ruff format --check pass.
  • uv run --group typing mypy sentry_sdk passes with no issues.
  • TESTPATH="tests/test_utils.py tests/test_basics.py tests/test_client.py" uv run tox -e py3.14-common: 587 passed, 3 skipped.

Issues

None. Found by a dead-code sweep.

via automation sched_65eed06cc199036c2b13411096f412d4 · Run ID sched_65eed06cc199036c2b13411096f412d4:1793267961442.

--

View Junior Session [Sentry]

The last callers of to_timestamp were removed with the old metrics code
in #4899. epoch was only used by to_timestamp.
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner October 29, 2026 10:04
@sentrivana
sentrivana enabled auto-merge (squash) October 29, 2026 10:06
@sentrivana
sentrivana merged commit 876a82f into master Oct 29, 2026
170 checks passed
@sentrivana
sentrivana deleted the ref/remove-unused-to-timestamp branch October 29, 2026 10:16
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 136856 passed | ⏭️ 7456 skipped | Total: 144312 | Pass Rate: 94.83% | Execution Time: 451m 50s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +228
Passed Tests 📈 +229
Failed Tests 📉 -1
Skipped Tests —

➖ Removed Tests (1)

View removed tests
  • test_cache_spans_item_size[True]
    • File: tests.integrations.django.test_cache_module

All tests are passing successfully.

✅ Patch coverage is 100.00% (no changed executable lines found; target 80%).
Project statement coverage is 90.29% (up 0.01 percentage points from base (63707d7) to head (991c3ec)).

Files with missing lines (1)
File Coverage % Lines
sentry_sdk/utils.py 91.87% ⚠️ 79 Missing and 34 partials
Coverage diff
@@            Coverage Diff             @@
##        master     #8147       +/-##
==========================================
+ Coverage    90.28%    90.29%    +0.01%
==========================================
  Files          203       203         —
  Tracked lines     26883     26880        -3
  Branches     10046     10046         —
==========================================
- Hits         24272     24271        -1
+ Misses        2611      2609        -2
+ Partials      1518      1517        -1

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