From 06bd0379e3c9e6725a2d7a48ba20a2a802d51edc Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Fri, 26 Jul 2024 19:04:49 -0400 Subject: [PATCH] ref: fix override of get_or_create --- src/sentry/models/commitauthor.py | 12 +++++++----- src/sentry/models/release.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sentry/models/commitauthor.py b/src/sentry/models/commitauthor.py index 59b56f4f83399..8b7de1c236701 100644 --- a/src/sentry/models/commitauthor.py +++ b/src/sentry/models/commitauthor.py @@ -1,6 +1,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, ClassVar +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, ClassVar from django.db import models @@ -13,13 +14,14 @@ class CommitAuthorManager(BaseManager["CommitAuthor"]): - def get_or_create(self, organization_id, email, defaults, **kwargs): + def get_or_create( + self, defaults: Mapping[str, Any] | None = None, **kwargs: Any + ) -> tuple[CommitAuthor, bool]: # Force email address to lowercase because many providers do this. Note though that this isn't technically # to spec; only the domain part of the email address is actually case-insensitive. # See: https://stackoverflow.com/questions/9807909/are-email-addresses-case-sensitive - return super().get_or_create( - organization_id=organization_id, email=email.lower(), defaults=defaults, **kwargs - ) + email = kwargs.pop("email").lower() + return super().get_or_create(defaults=defaults, email=email, **kwargs) @region_silo_model diff --git a/src/sentry/models/release.py b/src/sentry/models/release.py index 53bcfa9646b2c..f753cd8c17287 100644 --- a/src/sentry/models/release.py +++ b/src/sentry/models/release.py @@ -885,7 +885,7 @@ def set_commits(self, commit_list): (prr[0], pr_authors_dict.get(prr[1])) for prr in pull_request_resolutions ] - user_by_author: dict[str | None, RpcUser | None] = {None: None} + user_by_author: dict[CommitAuthor | None, RpcUser | None] = {None: None} commits_and_prs = list(itertools.chain(commit_group_authors, pull_request_group_authors))