Skip to content

fix(grouping): Resolve mypy possibly-undefined errors in grouphash caching#109602

Merged
scttcper merged 1 commit intomasterfrom
scttcper/fix-grouphash-mypy-possibly-undefined
Feb 27, 2026
Merged

fix(grouping): Resolve mypy possibly-undefined errors in grouphash caching#109602
scttcper merged 1 commit intomasterfrom
scttcper/fix-grouphash-mypy-possibly-undefined

Conversation

@scttcper
Copy link
Copy Markdown
Member

Hoist cache_key and cache_expiry assignments out of the first if use_caching: block in _grouphash_exists_for_hash_value and _get_or_create_single_grouphash.

mypy's --enable-error-code possibly-undefined couldn't track that the variables were guaranteed to be assigned by the time the second if use_caching: block ran, since it treats each conditional independently. Both values are side-effect-free to compute (a string format and an options dict lookup), so computing them unconditionally has no meaningful impact on the non-caching path.

…ching

Hoist `cache_key` and `cache_expiry` assignments out of the first
`if use_caching:` block so mypy can see they are always defined before
the second `if use_caching:` block that uses them. The values are
side-effect-free (string format + dict lookup) so computing them
unconditionally has no meaningful impact.

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 27, 2026
@scttcper scttcper marked this pull request as ready for review February 27, 2026 20:00
@scttcper scttcper requested a review from a team as a code owner February 27, 2026 20:00
@scttcper scttcper merged commit 9a20da1 into master Feb 27, 2026
77 checks passed
@scttcper scttcper deleted the scttcper/fix-grouphash-mypy-possibly-undefined branch February 27, 2026 21:20
jan-auer added a commit that referenced this pull request Mar 2, 2026
…ept-encoding

* origin/master: (63 commits)
  fix(api): Add missing cursor query parameter to paginated endpoint OpenAPI schemas (#109642)
  docs(sentry-apps): Add sentryAppId to sentry-app-installations API schema (#109628)
  feat(occurrences on eap): Implement double reads from EAP in organization events trace API endpoint (#109391)
  feat(occurrences on eap): Implement double reads from EAP for reprocessing2 flow (#109345)
  feat(ci): report backend test fails (#109543)
  feat(seer): Add signed viewer context header to Seer API requests (#109626)
  devenv: cleanup devenv-managed uv (#109617)
  feat(seer): Iterate on the instructions at the top of seer settings pages (#109586)
  ref(seer): Add typed wrappers for remaining Seer API callsites (#109607)
  feat(preprod): Make snapshots endpoint org scoped (#109575)
  chore: capture exception (#109620)
  fix(formatting): run ruff format (#109618)
  feat(preprod): Create admin gated recompare snapshots endpoint (#109546)
  feat(cells): expand locality/cell distinction (#109538)
  feat(cells): add db migration for synapse (#109615)
  feat(preprod): Add public install-details endpoint and shared utilities (#109583)
  fix(tests): Fix flaky test_cross_trace_query_with_spans_and_logs (#109572)
  fix(grouping): Resolve mypy possibly-undefined errors in grouphash caching (#109602)
  fix(dashboards): Default axisRange to auto for existing widgets in builder (#109598)
  fix(billing): Fix category display names in pending changes (#109612)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants