ref: Drop redundant casts in search builders#113426
Closed
JoshFerge wants to merge 1 commit into
Closed
Conversation
Three `cast(...)` calls that mypy 1.20.1 reports as redundant, and which are in fact redundant under 1.19.1 too (mypy already infers the narrowed type from the surrounding `if unit in constants.SIZE_UNITS` etc. checks). - `src/sentry/search/eap/columns.py`: drop `cast(constants.SearchType, ...)` inside a branch already guarded by membership in DURATION_TYPE/SIZE_TYPE. - `src/sentry/search/events/builder/base.py`: drop `cast(constants.SizeUnit, unit)` and `cast(constants.DurationUnit, unit)` inside the corresponding membership- checked branches. - `src/sentry/search/eap/trace_metrics/config.py`: drop `cast(TraceMetricType, metric_type)` where `metric_type` is already narrowed by `if ... not in ALLOWED_METRIC_TYPES` early-return. Prep for the mypy 1.20 upgrade (#113419). Agent transcript: https://claudescope.sentry.dev/share/rGGex5V3dtTetZqF-KULYaNyoOlBBLtcZWOK-0xI95U
Contributor
Author
|
Superseded by #113419, which already contains these exact cast drops. Closing as duplicate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three `cast(...)` calls that mypy already infers correctly — they fire `[redundant-cast]` under mypy 1.20.1 and are genuinely redundant under 1.19.1 too. Each is inside a branch already guarded by a membership check or early-return that narrows the value.
Prep for the mypy 1.20 upgrade (#113419). Safe under 1.19.1.
Agent transcript: https://claudescope.sentry.dev/share/lVivF9WN2X9tBvTh2KH4Va299tH3t04bTyP0awki7SU