Skip to content

chore(django): Use iscoroutinefunction shim in patch_views() - #7024

Merged
alexander-alderman-webb merged 2 commits into
masterfrom
webb/django-views-iscoroutinefunction
Aug 4, 2026
Merged

chore(django): Use iscoroutinefunction shim in patch_views()#7024
alexander-alderman-webb merged 2 commits into
masterfrom
webb/django-views-iscoroutinefunction

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

Re-use the existing shim in django.asgi that vendors asgiref.sync.iscoroutinefunction().

The views.py and asgi.py files were split to keep Python 2 compatibility in #851.

As we no longer support Python 2, we can unconditionally import asgi.py in views.py.

Issues

Closes #4900

Reminders

@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review August 4, 2026 06:42
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner August 4, 2026 06:42
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

95563 passed | ⏭️ 6239 skipped | Total: 101802 | Pass Rate: 93.87% | Execution Time: 341m 16s

📊 Comparison with Base Branch

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

➖ Removed Tests (1)

View removed tests
  • test_continuous_profiler_auto_start_and_stop_sampled_span_streaming[experiment-thread]
    • File: tests.profiler.test_continuous_profiler

All tests are passing successfully.

✅ Patch coverage is 83.33%. Project has 2504 uncovered lines.
✅ Project coverage is 89.91%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/django/views.py 83.33% ⚠️ 1 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.90%    89.91%    +0.01%
==========================================
  Files          193       193         —
  Lines        24834     24825        -9
  Branches      8912      8912         —
==========================================
+ Hits         22326     22321        -5
- Misses        2508      2504        -4
- Partials      1415      1414        -1

Generated by Codecov Action

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Small suggestion

Comment thread sentry_sdk/integrations/django/views.py Outdated
@alexander-alderman-webb alexander-alderman-webb changed the title chore(django): Use iscoroutinefunction shim in patch_views Aug 4, 2026
@alexander-alderman-webb
alexander-alderman-webb merged commit 3e96fc3 into master Aug 4, 2026
145 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/django-views-iscoroutinefunction branch August 4, 2026 07:57
mgaligniana pushed a commit to mgaligniana/sentry-python that referenced this pull request Aug 9, 2026
…sentry#7024)

Re-use the existing shim in `django.asgi`.
The shim vendors `asgiref.sync.iscoroutinefunction()`, used in Django to determine if a function is considered to be async or sync.

Co-authored-by: Digenis <digenishjkl@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants