Skip to content

ci(mypy): Enable deprecated error code - #8289

Draft
sentry-junior[bot] wants to merge 2 commits into
masterfrom
ci/mypy-deprecated
Draft

sentry-junior[bot] wants to merge 2 commits into
masterfrom
ci/mypy-deprecated

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Description

Turns on mypy's deprecated error code. It flags uses of APIs marked @deprecated (PEP 702) in typeshed, library stubs, or our own code, so we notice APIs that are about to be removed (e.g. asyncio.iscoroutinefunction(), gone in Python 3.16) before they break at runtime.

The existing 14 errors are handled like this:

  • OpenAI Responses API output: .dict() → .model_dump(). openai's BaseModel provides model_dump() on both pydantic v1 and v2 since openai 1.0, and the Chat Completions branch of the same function already uses it. Output is identical; it also avoids pydantic v2's runtime DeprecationWarning.
  • asyncio.iscoroutinefunction (asgi, django, fastapi, quart, starlette): # type: ignore[deprecated]. These are already version-guarded to use inspect.iscoroutinefunction on newer Pythons; mypy runs with python_version = "3.11" and only sees the fallback branch, which older Pythons still need.
  • Starlite BaseModel.dict(): ignored, since Starlite requires pydantic<2 and model_dump() doesn't exist there.
  • OTel SpanAttributes: ignored. The replacement opentelemetry.semconv.attributes constants use renamed attributes (e.g. http.request.method vs http.method), so switching would change what we read from instrumentations.

No real bugs found.

enable_error_code sits on the same pyproject.toml line as in #8281 and the sibling follow-up PRs, so expect a trivial conflict; merge the lists.

Follow-up from #8281.

via @sentrivana.

--

View Session [Sentry]

Co-Authored-By: Ivana Kellyer <131587164+sentrivana@users.noreply.github.com>
# Conflicts:
#	pyproject.toml
#	sentry_sdk/integrations/asgi.py
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 139266 passed | ⏭️ 7853 skipped | Total: 147119 | Pass Rate: 94.66% | Execution Time: 453m 59s

📊 Comparison with Base Branch

Metric Change
Total Tests —
Passed Tests —
Failed Tests —
Skipped Tests —

✨ Test counts unchanged from base.

All tests are passing successfully.

✅ Patch coverage is 83.33% (10 of 12 changed executable lines covered; target 80%).
Project statement coverage is 90.22% (unchanged from base (4c1a136) to head (2a387f0)).

Changed files with executable lines (8)
File Patch coverage Changed executable lines
sentry_sdk/integrations/openai.py 66.67% 2/3 covered; missed: 800
sentry_sdk/integrations/starlite.py 0.00% 0/1 covered; missed: 309
sentry_sdk/integrations/asgi.py 100.00% 2/2 covered
sentry_sdk/integrations/django/asgi.py 100.00% 2/2 covered
sentry_sdk/integrations/django/views.py 100.00% 1/1 covered
sentry_sdk/integrations/opentelemetry/span_processor.py 100.00% 1/1 covered
sentry_sdk/integrations/quart.py 100.00% 1/1 covered
sentry_sdk/integrations/starlette.py 100.00% 1/1 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8289       +/-##
==========================================
  Coverage    90.22%    90.22%        —%
==========================================
  Files          203       203         —
  Tracked lines     27335     27335         —
  Branches     10246     10246         —
==========================================
+ Hits         24660     24661        +1
+ Misses        2675      2674        -1
+ Partials      1559      1558        -1

Generated by Coverage Action

This branch has not been deployed

No deployments
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