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.

saml: Use match syntax for parsing groups config.

Mateusz Mandera1f602f8c038d
diff --git a/zproject/backends.py b/zproject/backends.py
index 044e12dedec..974aaef5d5d 100644
--- a/zproject/backends.py
+++ b/zproject/backends.py
@@ -1934,14 +1934,16 @@ def process_social_auth_group_sync_info(
assert backend.name == "saml"
for group_name in groups_config_list:
- # the objects in the config are either straight-forward group names
- # or tuples (<saml group name>, <zulip group name>) indicating the
- # obvious mapping.
- if isinstance(group_name, str):
- external_group_name_to_zulip_group_name[group_name] = group_name
- else:
- saml_group_name, zulip_group_name = group_name
- external_group_name_to_zulip_group_name[saml_group_name] = zulip_group_name
+ match group_name:
+ # the objects in the config are either straight-forward group names
+ # or tuples (<saml group name>, <zulip group name>) indicating the
+ # obvious mapping.
+ case str():
+ external_group_name_to_zulip_group_name[group_name] = group_name
+ case (saml_group_name, zulip_group_name):
+ external_group_name_to_zulip_group_name[saml_group_name] = zulip_group_name
+ case _: # nocoverage
+ raise AssertionError(f"Unsupported item in group sync config list: {group_name}")
syncable_group_names = set(external_group_name_to_zulip_group_name.values())