Skip to content

Commit

Permalink
ref: type the return value of Fixtures.create_user
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Nov 14, 2024
1 parent 00ea404 commit beb8ef7
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/sentry/incidents/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def generate_incident_activity_email(


def build_activity_context(
activity: IncidentActivity, user: RpcUser, activity_user: RpcUser | None = None
activity: IncidentActivity, user: RpcUser | User, activity_user: RpcUser | None = None
) -> dict[str, Any]:
if activity_user is None:
activity_user = user_service.get_user(user_id=activity.user_id)
Expand Down
9 changes: 6 additions & 3 deletions src/sentry/models/groupassignee.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

class GroupAssigneeManager(BaseManager["GroupAssignee"]):
def get_assigned_to_data(
self, assigned_to: Team | RpcUser, assignee_type: str, extra: dict[str, str] | None = None
self,
assigned_to: Team | RpcUser | User,
assignee_type: str,
extra: dict[str, str] | None = None,
) -> dict[str, Any]:
data = {
"assignee": str(assigned_to.id),
Expand All @@ -45,7 +48,7 @@ def get_assigned_to_data(

return data

def get_assignee_data(self, assigned_to: Team | RpcUser) -> tuple[str, str, str]:
def get_assignee_data(self, assigned_to: Team | RpcUser | User) -> tuple[str, str, str]:
from sentry.models.team import Team
from sentry.users.models.user import User
from sentry.users.services.user import RpcUser
Expand Down Expand Up @@ -130,7 +133,7 @@ def remove_old_assignees(
def assign(
self,
group: Group,
assigned_to: Team | RpcUser,
assigned_to: Team | RpcUser | User,
acting_user: User | None = None,
create_only: bool = False,
extra: dict[str, str] | None = None,
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/plugins/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from sentry.exceptions import InvalidIdentity, PluginError
from sentry.integrations.services.integration import integration_service
from sentry.organizations.services.organization.serial import serialize_rpc_organization
from sentry.users.models.user import User
from sentry.users.services.user import RpcUser
from sentry.users.services.usersocialauth.model import RpcUserSocialAuth
from sentry.users.services.usersocialauth.service import usersocialauth_service
Expand Down Expand Up @@ -98,7 +99,7 @@ def needs_auth(self, user, **kwargs):
)
return len(auths) == 0

def get_auth(self, user: RpcUser, **kwargs) -> RpcUserSocialAuth | None:
def get_auth(self, user: RpcUser | User, **kwargs) -> RpcUserSocialAuth | None:
if self.auth_provider is None:
return None

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/testutils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ def create_identity_provider(
@staticmethod
@assume_test_silo_mode(SiloMode.CONTROL)
def create_identity(
user: Any, identity_provider: IdentityProvider, external_id: str, **kwargs: Any
user: User | RpcUser, identity_provider: IdentityProvider, external_id: str, **kwargs: Any
) -> Identity:
return Identity.objects.create(
external_id=external_id,
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/testutils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def create_commit_author(self, *args, **kwargs):
def create_commit_file_change(self, *args, **kwargs):
return Factories.create_commit_file_change(*args, **kwargs)

def create_user(self, *args, **kwargs):
def create_user(self, *args, **kwargs) -> User:
return Factories.create_user(*args, **kwargs)

def create_useremail(self, *args, **kwargs):
Expand Down Expand Up @@ -536,7 +536,7 @@ def create_slack_integration(
self,
organization: Organization,
external_id: str = "TXXXXXXX1",
user: RpcUser | None = None,
user: RpcUser | User | None = None,
identity_external_id: str = "UXXXXXXX1",
**kwargs: Any,
):
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/users/api/bases/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class RegionSiloUserEndpoint(Endpoint):
permission_classes = (UserPermission,)

def convert_args(
self, request: Request, user_id: str | None = None, *args: Any, **kwargs: Any
self, request: Request, user_id: int | str | None = None, *args: Any, **kwargs: Any
) -> Any:
user: RpcUser | User | None = None

Expand Down
5 changes: 3 additions & 2 deletions tests/sentry/integrations/msteams/test_message_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
DummyNotificationWithMoreFields,
)
from sentry.testutils.skips import requires_snuba
from sentry.types.actor import Actor

pytestmark = [requires_snuba]

Expand Down Expand Up @@ -484,7 +485,7 @@ def test_simple(self):
notification_card = MSTeamsNotificationsMessageBuilder(
self.notification,
self.context,
self.recipient,
Actor.from_object(self.recipient),
).build_notification_card()

body = notification_card["body"]
Expand Down Expand Up @@ -520,7 +521,7 @@ def test_without_footer(self):
notification_card = MSTeamsNotificationsMessageBuilder(
dummy_notification,
self.context,
self.recipient,
Actor.from_object(self.recipient),
).build_notification_card()

assert 2 == len(notification_card["body"])
4 changes: 2 additions & 2 deletions tests/sentry/integrations/test_notification_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_matching_idp_and_identity_external_id(self):
"""
integrations_by_channel_by_recipient = get_integrations_by_channel_by_recipient(
self.notification.organization,
[self.user_2],
[Actor.from_object(self.user_2)],
ExternalProviders.SLACK,
)

Expand All @@ -68,7 +68,7 @@ def test_matching_idp_and_identity_external_id(self):
def test_multiple(self):
integrations_by_channel_by_recipient = get_integrations_by_channel_by_recipient(
self.notification.organization,
[self.user, self.user_2],
[Actor.from_object(self.user), Actor.from_object(self.user_2)],
ExternalProviders.SLACK,
)

Expand Down

0 comments on commit beb8ef7

Please sign in to comment.