Skip to content

fix(automation): avoid shared mutable default in Automation constructor - #3743

Open
Herklos wants to merge 1 commit into
devfrom
cursor/avoid-shared-mutable-default-automation-c9f1
Open

Herklos wants to merge 1 commit into
devfrom
cursor/avoid-shared-mutable-default-automation-c9f1

Conversation

@Herklos

@Herklos Herklos commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Stop Automation.__init__ from sharing a single default dict object across every instance built without an explicit config.

Solve the issue: none (TODO card: Avoid shared mutable default in Automation constructor)

Changelog

  • Automation.__init__ takes automations_config: Optional[dict] = None instead of a {} literal default.
  • When no config is given, a fresh {} is created per instance.
  • Added a unit test asserting two instances built without config do not share the dict.

What's new?

automations_config was 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 None and 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.
  • New test test_default_automations_config_is_not_shared fails 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).
Open in Web Open in Cursor 

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>
@Herklos
Herklos requested a review from GuillaumeDSM as a code owner October 13, 2026 13:35
@Herklos Herklos self-assigned this Oct 13, 2026

This branch has not been deployed

No deployments
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.

2 participants