pasqal-io / qadence

Digital-analog quantum programming interface
https://pasqal-io.github.io/qadence/latest/
Apache License 2.0
72 stars 21 forks source link

Replace empty lists, and dicts by default `None` on functions and methods args #590

Closed Doomsk closed 3 weeks ago

Doomsk commented 1 month ago

Short description

Empty lists, tuples, dicts as defaults on functions and methods declarations are prone to changing their default values if the variable in the argument is changed throughout the function/method scope.

What is the expected result?

No response

What is the actual result?

No response

Steps/Code to reproduce


def fn(x=[]):
    x.append(1)
    return x

print(fn())
print(fn([2,3]))
print(fn())

Tracebacks (optional)

No response

Environment details (optional)

No response

Would you like to work on this issue?

Yes

chMoussa commented 3 weeks ago

Closing with #594