From 11e913cd854c6de35f305a371bfff56c2e88c8ad Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2020 10:29:25 +0000 Subject: [PATCH] Fix dangerous default argument --- dangerous_default_arg_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dangerous_default_arg_test.py b/dangerous_default_arg_test.py index b3e4280b..5e8bbf71 100644 --- a/dangerous_default_arg_test.py +++ b/dangerous_default_arg_test.py @@ -2,14 +2,20 @@ import os -def some_func(arg1, arg2, arg3=[1, 2, 3], arg4=None, arg5={1,2}): +def some_func(arg1, arg2, arg3=None, arg4=None, arg5=None): """ Some docstring to ensure docstring stay at its position """ + if arg3 is None: + arg3 = [1, 2, 3] + if arg5 is None: + arg5 = {1,2} print("I am a function!") - def some_other_func(arg=[1,2,3]): + def some_other_func(arg=None): """Nested function to ensure indentation doesn't get messed up""" + if arg is None: + arg = [1,2,3] x = [1,2,3]; y={1, 2, 3}; z={'a': 1, 'b': 2}; t=(1, 2, 3) def another_nested_function(danger_one=x, danger_two=y, danger_three=z, xyz=None, safe_four=t):