Skip to content

refactor: replace dangerous mutable default argument#23

Open
deepsource-dev-autofix[bot] wants to merge 1 commit intomasterfrom
deepsource-autofix-f4716403
Open

refactor: replace dangerous mutable default argument#23
deepsource-dev-autofix[bot] wants to merge 1 commit intomasterfrom
deepsource-autofix-f4716403

Conversation

@deepsource-dev-autofix
Copy link

Fixes are generated by AI. Review them carefully before applying to your codebase.

This PR refactors function parameters to avoid mutable default arguments and prevent state persistence across calls.

  • Dangerous default argument: Functions using mutable defaults such as lists or dictionaries may retain state across invocations, leading to unintended side effects. We replaced the default argument with None and added a conditional inside the function to initialize a new object when the parameter is None. This ensures each function call operates on a fresh instance and avoids persistent state issues.

**Fixes are generated by AI. Review them carefully before applying to your codebase.**

This PR refactors function parameters to avoid mutable default arguments and prevent state persistence across calls.

- Dangerous default argument: Functions using mutable defaults such as lists or dictionaries may retain state across invocations, leading to unintended side effects. We replaced the default argument with None and added a conditional inside the function to initialize a new object when the parameter is None. This ensures each function call operates on a fresh instance and avoids persistent state issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants

Comments