Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: fix override of get_or_create #75108

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/sentry/models/commitauthor.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
Comment on lines +23 to +24
Copy link
Member

Choose a reason for hiding this comment

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

Should we also check for organization_id here?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's non-null so the underlying call will do that for us



@region_silo_model
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/models/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Loading