Skip to content

Commit

Permalink
fix: Avoid bugs around mutating configs by ensuring they are always r…
Browse files Browse the repository at this point in the history
…eferentially unique
  • Loading branch information
nickderobertis committed Aug 14, 2022
1 parent 599d2fb commit 1c127f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flexlate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ def from_multiple(cls, configs: Sequence["FlexlateConfig"]) -> "FlexlateConfig":
template_sources: List[TemplateSource] = []
applied_templates: List[AppliedTemplateConfig] = []
for conf in configs:
template_sources.extend(conf.template_sources)
applied_templates.extend(conf.applied_templates)
# Copy to avoid bugs from mutating the configs
# When updating, always update both the child and root config
template_sources.extend([ts.copy() for ts in conf.template_sources])
applied_templates.extend([at.copy() for at in conf.applied_templates])
obj = cls(
template_sources=template_sources, applied_templates=applied_templates
)
Expand Down

0 comments on commit 1c127f5

Please sign in to comment.