Repository navigation
Conversation
Default automations_config to None and normalize to a fresh dict in __init__ so instances built without an explicit config do not share one dict object. Co-authored-by: herklos.dev <herklos.dev@protonmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop
Automation.__init__from sharing a single defaultdictobject across every instance built without an explicit config.Solve the issue: none (TODO card: Avoid shared mutable default in Automation constructor)
Changelog
Automation.__init__takesautomations_config: Optional[dict] = Noneinstead of a{}literal default.{}is created per instance.What's new?
automations_configwas declared with a mutable{}default, so the same dict object was shared by all instances created without an explicit config (flagged by ruff B006). No code path mutated it today, so impact is low, but it is a trap for future edits.The default is now
Noneand is normalized to a fresh dict inside__init__. An explicitly passed config (including an empty one) is kept as-is.Verification
pytest tests/unit_tests/automation: 70 passed.test_default_automations_config_is_not_sharedfails on the previous code and passes with this change.pytest tests/functional_tests/automations: 3 passed.python -m tools.extended_linter --base origin/dev: OK (0 violations).