Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ruff: Fix SIM118 Use `k not in d` instead of `k not in d.keys()`.

Anders Kaseorg74d6d7604649
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index 731d30d23a4..45abe3e25a3 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -873,7 +873,7 @@ def check_realm_update(
assert "extra_data" in event
return
- assert "extra_data" not in event.keys()
+ assert "extra_data" not in event
if prop in ["notifications_stream_id", "signup_notifications_stream_id", "org_type"]:
assert isinstance(value, int)
@@ -1472,7 +1472,7 @@ def check_update_display_settings(
if setting_name == "default_language":
assert "language_name" in event
else:
- assert "language_name" not in event.keys()
+ assert "language_name" not in event
def check_user_settings_update(
@@ -1493,7 +1493,7 @@ def check_user_settings_update(
if setting_name == "default_language":
assert "language_name" in event
else:
- assert "language_name" not in event.keys()
+ assert "language_name" not in event
update_global_notifications_event = event_dict_type(
diff --git a/zerver/lib/external_accounts.py b/zerver/lib/external_accounts.py
index 94f25bc8317..2bd07779508 100644
--- a/zerver/lib/external_accounts.py
+++ b/zerver/lib/external_accounts.py
@@ -65,9 +65,9 @@ def validate_external_account_field_data(field_data: ProfileFieldData) -> Profil
field_validator("field_data", field_data)
field_subtype = field_data.get("subtype")
- if field_subtype not in DEFAULT_EXTERNAL_ACCOUNTS.keys():
+ if field_subtype not in DEFAULT_EXTERNAL_ACCOUNTS:
if field_subtype == "custom":
- if "url_pattern" not in field_data.keys():
+ if "url_pattern" not in field_data:
raise ValidationError(_("Custom external account must define URL pattern"))
else:
raise ValidationError(_("Invalid external account type"))
diff --git a/zerver/openapi/openapi.py b/zerver/openapi/openapi.py
index 6698d6d8991..14aba7c347a 100644
--- a/zerver/openapi/openapi.py
+++ b/zerver/openapi/openapi.py
@@ -375,7 +375,7 @@ def validate_against_openapi_schema(
# No 500 responses have been documented, so skip them
if status_code.startswith("5"):
return False
- if path not in openapi_spec.openapi()["paths"].keys():
+ if path not in openapi_spec.openapi()["paths"]:
endpoint = find_openapi_endpoint(path)
# If it doesn't match it hasn't been documented yet.
if endpoint is None:
diff --git a/zerver/webhooks/opbeat/view.py b/zerver/webhooks/opbeat/view.py
index b741b95bc05..51990953c7d 100644
--- a/zerver/webhooks/opbeat/view.py
+++ b/zerver/webhooks/opbeat/view.py
@@ -62,7 +62,7 @@ def format_object(
subject_type: str,
message: str,
) -> str:
- if subject_type not in subject_types.keys():
+ if subject_type not in subject_types:
return message
keys: List[List[str]] = subject_types[subject_type][1:]
title = subject_types[subject_type][0]