ioxu / boxer

workflow tool
MIT License
1 stars 0 forks source link

Container: `.update_structure()` and the mutable default argument #7

Closed ioxu closed 11 months ago

ioxu commented 11 months ago

Fix handling of leave argument in .update_structure().

https://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument

Change leaves : list = list() to leaves : list = None and in body use

if leaves is None:
    leaves = []

The linter warned me with this:

Dangerous default value list() (builtins.list) as argumentPylintW0102:dangerous-default-value

and now I now what that means.

It caught me in .remove_children()

def remove_children(self, old_children = []) -> list:

became

def remove_children(self, old_children = None) -> list: