Skip to content

fix: use non-mutable default arguments

Jonas Eschle requested to merge je_fix_mutable_defaults into master

I've found a few mutable input arguments that possibly have non-desired effects: if a function is called multiple times and the input argument is mutated, the default argument, being the same object, changes too.

def func(a=[]):
   a.append(1)
   print(a)

func()  # prints [1]
func()  # print [1, 1]
func()  # print [1, 1, 1]
...

Merge request reports