aboutsummaryrefslogtreecommitdiff
path: root/gn3/authentication.py
diff options
context:
space:
mode:
authorArun Isaac2021-11-10 15:47:20 +0530
committerBonfaceKilz2021-11-13 08:00:40 +0300
commit0059de6c028996c9b21a833f186ba7df4899fa2d (patch)
treefc686e09418ccd11775ecc8ede2da78979e37278 /gn3/authentication.py
parent85405fe6875358d3bb98b03621271d5909dd393f (diff)
downloadgenenetwork3-0059de6c028996c9b21a833f186ba7df4899fa2d.tar.gz
Do not use dangerous default argument [].
Default arguments get evaluated only once when the function is defined, and are then shared across all instances of the function. If the argument is then mutated, this can cause hard to find bugs. See https://docs.python.org/3/tutorial/controlflow.html#default-argument-values * gn3/authentication.py (create_group): Do not use [] as the default argument.
Diffstat (limited to 'gn3/authentication.py')
-rw-r--r--gn3/authentication.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gn3/authentication.py b/gn3/authentication.py
index 6719631..1ccffcc 100644
--- a/gn3/authentication.py
+++ b/gn3/authentication.py
@@ -145,9 +145,13 @@ def get_user_info_by_key(key: str, value: str,
def create_group(conn: Redis, group_name: Optional[str],
- admin_user_uids: List = [],
- member_user_uids: List = []) -> Optional[Dict]:
+ admin_user_uids: List = None,
+ member_user_uids: List = None) -> Optional[Dict]:
"""Create a group given the group name, members and admins of that group."""
+ if admin_user_uids is None:
+ admin_user_uids = []
+ if member_user_uids is None:
+ member_user_uids = []
if group_name and bool(admin_user_uids + member_user_uids):
timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p')
group = {