Skip to content

[BUG] mutable object as default values #587

@VukW

Description

@VukW

In some places we are using {} as default function param values. However this is error-prone as these default values are mutable and can be modified unexpectedly during the call:

In [1]: def fun(d={}):
   ...:     d['count'] = d.get('count', 0) + 1
   ...:     print(d)
   ...:

In [2]: fun()
{'count': 1}

In [3]: fun()
{'count': 2}  # default value was modified

Right now it doesn't break anything, but it's worth to fix these cases, not using mutable objects as default values

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions