Skip to content

types(incidents): Stronglist sentry.incidents.metric_issue_detector#112638

Merged
kcons merged 1 commit intomasterfrom
kcons/strongerplz
Apr 9, 2026
Merged

types(incidents): Stronglist sentry.incidents.metric_issue_detector#112638
kcons merged 1 commit intomasterfrom
kcons/strongerplz

Conversation

@kcons
Copy link
Copy Markdown
Member

@kcons kcons commented Apr 9, 2026

This not being strongly typed allowed a bug to sneak into another PR.
Doing this first and merging it forst allows us to prevent that bug in the future without complicating that other PR.

@kcons kcons requested review from a team as code owners April 9, 2026 23:02
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 9, 2026
Copy link
Copy Markdown
Contributor

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

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

yay more types!


def validate_comparison(self, value: dict | float | int | str) -> float | dict:
def validate_comparison(
self, value: dict[str, Any] | float | int | str
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.

should we have stronger types around the values here? Like have BaseJSONConfig or something export this as a named type; JSONPrimitive or something? (although, this wouldn't include arrays 🤔)

conditions = serializers.ListField(required=True)

def validate_conditions(self, value):
def validate_conditions(self, value: list[dict[str, Any]]) -> list[dict[str, Any]]:
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.

similar thought about giving this dict[str, Any] a name; ValidatedCondition or something for the result?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

in these cases (ie validate_* methods) I'm not sure we can actually rely on the type being anything more specific than what the named field verifies, so we may be being too specific already. I didn't dig deep to verify though; the aim here is mostly to get type validation elsewhere where I'd been assuming it and surprised that clearly invalid stuff wasn't flagged, so the annotations to get into the stronglist were just trying to be basically correct and not missing.

@kcons kcons enabled auto-merge (squash) April 9, 2026 23:16
@kcons kcons merged commit d9ac5bc into master Apr 9, 2026
80 checks passed
@kcons kcons deleted the kcons/strongerplz branch April 9, 2026 23:18
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