25
25
from sentry .models .releases .release_project import ReleaseProject
26
26
from sentry .release_health .base import ReleaseHealthOverview
27
27
from sentry .users .api .serializers .user import UserSerializerResponse
28
+ from sentry .users .models .user import User
29
+ from sentry .users .services .user .model import RpcUser
28
30
from sentry .users .services .user .serial import serialize_generic_user
29
31
from sentry .users .services .user .service import user_service
30
32
from sentry .utils import metrics
@@ -111,7 +113,13 @@ def _expose_current_project_meta(current_project_meta):
111
113
return rv
112
114
113
115
114
- def _get_authors_metadata (item_list , user ):
116
+ class _AuthorList (TypedDict ):
117
+ authors : list [Author ]
118
+
119
+
120
+ def _get_authors_metadata (
121
+ item_list : list [Release ], user : User | RpcUser | AnonymousUser
122
+ ) -> dict [Release , _AuthorList ]:
115
123
"""
116
124
Returns a dictionary of release_id => authors metadata,
117
125
where each commit metadata dict contains an array of
@@ -126,7 +134,8 @@ def _get_authors_metadata(item_list, user):
126
134
"""
127
135
author_ids = set ()
128
136
for obj in item_list :
129
- author_ids .update (obj .authors )
137
+ if obj .authors is not None :
138
+ author_ids .update (obj .authors )
130
139
131
140
if author_ids :
132
141
authors = list (CommitAuthor .objects .filter (id__in = author_ids ))
@@ -144,18 +153,17 @@ def _get_authors_metadata(item_list, user):
144
153
else :
145
154
users_by_author = {}
146
155
147
- result = {}
156
+ result : dict [ Release , _AuthorList ] = {}
148
157
for item in item_list :
149
158
item_authors = []
150
159
seen_authors = set ()
151
- for user in (users_by_author .get (a ) for a in item .authors ):
152
- if user and user ["email" ] not in seen_authors :
153
- seen_authors .add (user ["email" ])
154
- item_authors .append (user )
160
+ if item .authors is not None :
161
+ for user_resp in (users_by_author .get (a ) for a in item .authors ):
162
+ if user_resp and user_resp ["email" ] not in seen_authors :
163
+ seen_authors .add (user_resp ["email" ])
164
+ item_authors .append (user_resp )
155
165
156
- result [item ] = {
157
- "authors" : item_authors ,
158
- }
166
+ result [item ] = {"authors" : item_authors }
159
167
return result
160
168
161
169
@@ -226,7 +234,9 @@ class NonMappableUser(TypedDict):
226
234
227
235
228
236
def get_users_for_authors (
229
- organization_id : int , authors : list [CommitAuthor ], user = None
237
+ organization_id : int ,
238
+ authors : list [CommitAuthor ],
239
+ user : User | AnonymousUser | RpcUser | None = None ,
230
240
) -> Mapping [str , Author ]:
231
241
"""
232
242
Returns a dictionary of author_id => user, if a Sentry
0 commit comments