Skip to content

Commit aad06d1

Browse files
committed
Fix BaseUserSerializer get_url typehint
1 parent e720621 commit aad06d1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/olympia/accounts/serializers.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,20 @@ class Meta:
3535
model = UserProfile
3636
fields = ('id', 'name', 'url', 'username')
3737

38-
def get_url(self, obj):
38+
def get_url(self, obj) -> str | None:
3939
def is_adminish(user):
40-
return user and acl.action_allowed_for(user, amo.permissions.USERS_EDIT)
40+
return (
41+
acl.action_allowed_for(user, amo.permissions.USERS_EDIT)
42+
if user
43+
else False
44+
)
4145

4246
request = self.context.get('request', None)
4347
current_user = getattr(request, 'user', None) if request else None
4448
# Only return your own profile url, and for developers.
4549
if obj == current_user or is_adminish(current_user) or obj.is_public:
4650
return obj.get_absolute_url()
51+
return None
4752

4853
# Used in subclasses.
4954
def get_permissions(self, obj):

0 commit comments

Comments
 (0)