mirror of https://github.com/zulip/zulip.git
ruff: Fix PERF403 Use a dictionary comprehension instead of a for-loop.
This is a preview rule, not yet enabled by default. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
82a9fd927b
commit
87992b8b29
|
@ -485,9 +485,7 @@ def sort_by_totals(value_arrays: Dict[str, List[int]]) -> List[str]:
|
|||
def sort_client_labels(data: Dict[str, Dict[str, List[int]]]) -> List[str]:
|
||||
realm_order = sort_by_totals(data["everyone"])
|
||||
user_order = sort_by_totals(data["user"])
|
||||
label_sort_values: Dict[str, float] = {}
|
||||
for i, label in enumerate(realm_order):
|
||||
label_sort_values[label] = i
|
||||
label_sort_values: Dict[str, float] = {label: i for i, label in enumerate(realm_order)}
|
||||
for i, label in enumerate(user_order):
|
||||
label_sort_values[label] = min(i - 0.1, label_sort_values.get(label, i))
|
||||
return [label for label, sort_value in sorted(label_sort_values.items(), key=lambda x: x[1])]
|
||||
|
|
|
@ -554,20 +554,8 @@ def get_system_user_group_for_user(user_profile: UserProfile) -> UserGroup:
|
|||
|
||||
|
||||
def get_server_supported_permission_settings() -> ServerSupportedPermissionSettings:
|
||||
realm_permission_group_settings: Dict[str, GroupPermissionSetting] = {}
|
||||
for permission_name, permission_config in Realm.REALM_PERMISSION_GROUP_SETTINGS.items():
|
||||
realm_permission_group_settings[permission_name] = permission_config
|
||||
|
||||
stream_permission_group_settings: Dict[str, GroupPermissionSetting] = {}
|
||||
for permission_name, permission_config in Stream.stream_permission_group_settings.items():
|
||||
stream_permission_group_settings[permission_name] = permission_config
|
||||
|
||||
group_permission_settings: Dict[str, GroupPermissionSetting] = {}
|
||||
for permission_name, permission_config in UserGroup.GROUP_PERMISSION_SETTINGS.items():
|
||||
group_permission_settings[permission_name] = permission_config
|
||||
|
||||
return ServerSupportedPermissionSettings(
|
||||
realm=realm_permission_group_settings,
|
||||
stream=stream_permission_group_settings,
|
||||
group=group_permission_settings,
|
||||
realm=Realm.REALM_PERMISSION_GROUP_SETTINGS,
|
||||
stream=Stream.stream_permission_group_settings,
|
||||
group=UserGroup.GROUP_PERMISSION_SETTINGS,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue