mirror of https://github.com/zulip/zulip.git
ruff: Fix PERF102 Using only the keys/values of a dict.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
55aa29bef4
commit
c4748298bb
|
@ -53,7 +53,7 @@ EMOTICON_CONVERSIONS = {
|
|||
|
||||
def emoji_names_for_picker(emoji_name_maps: Dict[str, Dict[str, Any]]) -> List[str]:
|
||||
emoji_names: List[str] = []
|
||||
for emoji_code, name_info in emoji_name_maps.items():
|
||||
for name_info in emoji_name_maps.values():
|
||||
emoji_names.append(name_info["canonical_name"])
|
||||
emoji_names.extend(name_info["aliases"])
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ def build_customprofile_field(
|
|||
# The name of the custom profile field is not provided in the Slack data
|
||||
# Hash keys of the fields are provided
|
||||
# Reference: https://api.slack.com/methods/users.profile.set
|
||||
for field, value in fields.items():
|
||||
for field in fields:
|
||||
if field not in slack_custom_field_name_to_zulip_custom_field_id:
|
||||
slack_custom_fields = ["phone", "skype"]
|
||||
if field in slack_custom_fields:
|
||||
|
|
|
@ -367,9 +367,7 @@ def generic_bulk_cached_fetch(
|
|||
[cache_keys[object_id] for object_id in object_ids],
|
||||
)
|
||||
|
||||
cached_objects: Dict[str, CacheItemT] = {}
|
||||
for key, val in cached_objects_compressed.items():
|
||||
cached_objects[key] = extractor(cached_objects_compressed[key][0])
|
||||
cached_objects = {key: extractor(val[0]) for key, val in cached_objects_compressed.items()}
|
||||
needed_ids = [
|
||||
object_id for object_id in object_ids if cache_keys[object_id] not in cached_objects
|
||||
]
|
||||
|
|
|
@ -282,7 +282,7 @@ class TornadoInMemoryRateLimiterBackend(RateLimiterBackend):
|
|||
|
||||
@classmethod
|
||||
def clear_history(cls, entity_key: str) -> None:
|
||||
for rule, reset_times_for_rule in cls.reset_times.items():
|
||||
for reset_times_for_rule in cls.reset_times.values():
|
||||
reset_times_for_rule.pop(entity_key, None)
|
||||
cls.timestamps_blocked_until.pop(entity_key, None)
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ def get_stream_permission_policy_name(
|
|||
is_web_public: Optional[bool] = None,
|
||||
) -> str:
|
||||
policy_name = None
|
||||
for permission, permission_dict in Stream.PERMISSION_POLICIES.items():
|
||||
for permission_dict in Stream.PERMISSION_POLICIES.values():
|
||||
if (
|
||||
permission_dict["invite_only"] == invite_only
|
||||
and permission_dict["history_public_to_subscribers"] == history_public_to_subscribers
|
||||
|
|
|
@ -1558,7 +1558,7 @@ Output:
|
|||
"""
|
||||
directory = orjson.loads(self.fixture_data("directory.json", type="ldap"))
|
||||
|
||||
for dn, attrs in directory.items():
|
||||
for attrs in directory.values():
|
||||
if "uid" in attrs:
|
||||
# Generate a password for the LDAP account:
|
||||
attrs["userPassword"] = [self.ldap_password(attrs["uid"][0])]
|
||||
|
|
|
@ -145,7 +145,7 @@ class Command(compilemessages.Command):
|
|||
|
||||
# frontend stats
|
||||
with open(self.get_json_filename(locale_path, locale), "rb") as reader:
|
||||
for key, value in orjson.loads(reader.read()).items():
|
||||
for value in orjson.loads(reader.read()).values():
|
||||
total += 1
|
||||
if value == "":
|
||||
not_translated += 1
|
||||
|
|
|
@ -1064,7 +1064,7 @@ def avatar_changes_disabled(realm: Realm) -> bool:
|
|||
|
||||
|
||||
def get_org_type_display_name(org_type: int) -> str:
|
||||
for realm_type, realm_type_details in Realm.ORG_TYPES.items():
|
||||
for realm_type_details in Realm.ORG_TYPES.values():
|
||||
if realm_type_details["id"] == org_type:
|
||||
return realm_type_details["name"]
|
||||
|
||||
|
|
|
@ -1959,7 +1959,7 @@ class NormalActionsTest(BaseAction):
|
|||
check_user_group_add_members("events[3]", events[3])
|
||||
|
||||
def test_change_notification_settings(self) -> None:
|
||||
for notification_setting, v in self.user_profile.notification_setting_types.items():
|
||||
for notification_setting in self.user_profile.notification_setting_types:
|
||||
if notification_setting in [
|
||||
"notification_sound",
|
||||
"desktop_icon_count_display",
|
||||
|
|
|
@ -1345,8 +1345,7 @@ class SlackImporter(ZulipTestCase):
|
|||
self.assertEqual(Message.objects.filter(realm=realm).count(), 82)
|
||||
|
||||
# All auth backends are enabled initially.
|
||||
for name, enabled in realm.authentication_methods_dict().items():
|
||||
self.assertTrue(enabled)
|
||||
self.assertTrue(all(realm.authentication_methods_dict().values()))
|
||||
|
||||
Realm.objects.filter(name=test_realm_subdomain).delete()
|
||||
|
||||
|
|
Loading…
Reference in New Issue