Skip to content

Commit 6f51b8d

Browse files
schwehrGoogle Earth Engine Authors
authored and
Google Earth Engine Authors
committed
commands._apply_permissions(): Do a better job of convincing pytype that the typing is correct.
PiperOrigin-RevId: 688230061
1 parent d6408ad commit 6f51b8d

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

python/ee/cli/commands.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -569,27 +569,29 @@ def _apply_permissions(
569569
"""Applies the given permission edits to the given acl."""
570570
for user, role in permissions.items():
571571
if self._is_all_users(user):
572-
acl[ALL_USERS_CAN_READ] = (role == 'R')
572+
acl[ALL_USERS_CAN_READ] = role == 'R'
573573
else:
574+
readers = acl[READERS]
575+
writers = acl[WRITERS]
574576
# Make pytype understand the types.
575-
assert isinstance(acl[READERS], list)
576-
assert isinstance(acl[WRITERS], list)
577+
assert isinstance(readers, list)
578+
assert isinstance(writers, list)
577579

578580
if role == 'R':
579-
if user not in acl[READERS]:
580-
acl[READERS].append(user)
581-
if user in acl[WRITERS]:
582-
acl[WRITERS].remove(user)
581+
if user not in readers:
582+
readers.append(user)
583+
if user in writers:
584+
writers.remove(user)
583585
elif role == 'W':
584-
if user in acl[READERS]:
585-
acl[READERS].remove(user)
586-
if user not in acl[WRITERS]:
587-
acl[WRITERS].append(user)
586+
if user in readers:
587+
readers.remove(user)
588+
if user not in writers:
589+
writers.append(user)
588590
elif role == 'D':
589-
if user in acl[READERS]:
590-
acl[READERS].remove(user)
591-
if user in acl[WRITERS]:
592-
acl[WRITERS].remove(user)
591+
if user in readers:
592+
readers.remove(user)
593+
if user in writers:
594+
writers.remove(user)
593595

594596
def _is_all_users(self, user: str) -> bool:
595597
"""Determines if a user name represents the special "all users" entity."""

0 commit comments

Comments
 (0)