Skip to content

Commit

Permalink
refactor: fix dangerous default argument (#22)
Browse files Browse the repository at this point in the history
Do not use a mutable like `list` or `dictionary` as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
deepsource-autofix[bot] authored Jan 9, 2024
1 parent b58c865 commit e06a4ab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/plugins/nonebot_plugin_addFriend/configUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def check_dict_key_bot_id(config: dict, requestorDict: dict, numDict: dict, bot:
# return True


def readData(path, content={}, update=0) -> dict:
def readData(path, content=None, update=0) -> dict:
if content is None:
content = {}
if not exists(path):
with open(path, "w", encoding="utf-8") as fp:
json.dump(content, fp, ensure_ascii=False)
Expand Down

0 comments on commit e06a4ab

Please sign in to comment.