Skip to content

Conversation

@mchen-sentry
Copy link
Member

@mchen-sentry mchen-sentry commented Nov 3, 2025

This PR addresses the mpy crash error AssertionError: Must not defer during final iteration on src/sentry/deletions.

The recent change to reference ActorSerializerResponse instead of UserSerializerResponse introduced a new complex TypedDict to resolve in the inheritance chain, causing mypy to run out of iterations.

This bandaid fix skips the resolution WebhookGroupResponse --> BaseGroupSerializerResponse --> ActorSerializerResponse. Runtime behavior is identical, although we do lose type information. Another alternative solution is moving ActorSerializerResponse to a module outside of the SCC (e.g. to user.py).

Ideally we'd like to refactor the wildcard imports in src/sentry/api/serializers/models/__init__.py (creates a 2000+ module SCC).

@mchen-sentry mchen-sentry requested review from a team as code owners November 3, 2025 19:17
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2025
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #102605   +/-   ##
========================================
  Coverage   80.89%    80.89%           
========================================
  Files        8864      8864           
  Lines      390631    390696   +65     
  Branches    24839     24839           
========================================
+ Hits       316013    316070   +57     
- Misses      74252     74260    +8     
  Partials      366       366           

Copy link
Member

@joshuarli joshuarli left a comment

Choose a reason for hiding this comment

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

mypy src/sentry/deletions/__init__.py passes with this patch applied to 85b873ec3d9fbc6ec38f7c63fe83e832391ecb27. Same with other complex inits like mypy src/sentry/grouping/enhancer/__init__.py.

Good bandaid for now, but still unclear to me how to debug this kind of thing.

@mchen-sentry mchen-sentry merged commit f9bb816 into master Nov 3, 2025
86 checks passed
@mchen-sentry mchen-sentry deleted the fix/mingchen/mypy-crash-response-protocol branch November 3, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants