Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential mutable dict issue #44

Merged

Conversation

Snuffy2
Copy link
Contributor

@Snuffy2 Snuffy2 commented Aug 8, 2023

Function defaults are evaluated once, when the function is defined.

The same mutable object is then shared across all calls to the function. If the object is modified, those modifications will persist across calls, which can lead to unexpected behavior.

Instead, prefer to use immutable data structures, or take None as a default, and initialize a new mutable object inside the function body for each call.

custom_components/healthchecksio/config_flow.py Outdated Show resolved Hide resolved
custom_components/healthchecksio/config_flow.py Outdated Show resolved Hide resolved
custom_components/healthchecksio/config_flow.py Outdated Show resolved Hide resolved
@Snuffy2 Snuffy2 force-pushed the Fix-potential-mutable-dict-issue branch from 05d0479 to caf63bb Compare October 9, 2023 15:04
@Snuffy2 Snuffy2 requested a review from ludeeus October 9, 2023 15:05
Snuffy2 added a commit to Snuffy2/healthchecksio that referenced this pull request Oct 9, 2023
Copy link
Contributor Author

@Snuffy2 Snuffy2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as requested

@ludeeus ludeeus merged commit 33341cf into custom-components:main Oct 9, 2023
@Snuffy2 Snuffy2 deleted the Fix-potential-mutable-dict-issue branch October 9, 2023 18:24
@ludeeus ludeeus added the bugfix label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants