From 72f21c8d7927d9fa6110fd56da792d778f3c68e7 Mon Sep 17 00:00:00 2001 From: John Andersen Date: Wed, 22 Nov 2023 19:43:25 +0000 Subject: [PATCH] source: df: Ensure default_factory is used for mutable defaults (Python 3.12 support) Signed-off-by: John Andersen --- dffml/source/df.py | 5 +++-- dffml/source/dfpreprocess.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dffml/source/df.py b/dffml/source/df.py index 857be9164d..5454ae676e 100644 --- a/dffml/source/df.py +++ b/dffml/source/df.py @@ -19,7 +19,7 @@ class DataFlowSourceConfig: features: Features = field( "Features to pass as definitions to each context from each " "record to be preprocessed", - default=Features(), + default_factory=lambda: Features(), ) inputs: List[str] = field( "Other inputs to add under each ctx (record's key will " @@ -42,7 +42,8 @@ class DataFlowSourceConfig: "Do not exit on operation exceptions, just log errors", default=False, ) orchestrator: BaseOrchestrator = field( - "Orchestrator", default=MemoryOrchestrator.withconfig({}), + "Orchestrator", + default_factory=lambda: MemoryOrchestrator.withconfig({}), ) diff --git a/dffml/source/dfpreprocess.py b/dffml/source/dfpreprocess.py index 9cc79a438a..44401a47ae 100644 --- a/dffml/source/dfpreprocess.py +++ b/dffml/source/dfpreprocess.py @@ -21,7 +21,7 @@ class DataFlowPreprocessSourceConfig: features: Features = field( "Features to pass as definitions to each context from each " "record to be preprocessed", - default=Features(), + default_factory=lambda: Features(), ) inputs: List[str] = field( "Other inputs to add under each ctx (record's key will " @@ -47,7 +47,8 @@ class DataFlowPreprocessSourceConfig: "Do not exit on operation exceptions, just log errors", default=False, ) orchestrator: BaseOrchestrator = field( - "Orchestrator", default=MemoryOrchestrator.withconfig({}), + "Orchestrator", + default_factory=lambda: MemoryOrchestrator.withconfig({}), )