From 78f94f68a4dfa74157f43223d79989896d2c5c0f Mon Sep 17 00:00:00 2001 From: Nicholas Smith Date: Wed, 15 Jan 2025 10:55:32 -0600 Subject: [PATCH] Use discriminated union for nodetype (#272) --- src/correctionlib/schemav2.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/correctionlib/schemav2.py b/src/correctionlib/schemav2.py index 2073359..783ee84 100644 --- a/src/correctionlib/schemav2.py +++ b/src/correctionlib/schemav2.py @@ -70,13 +70,18 @@ def __rich__(self) -> str: # py3.7+: ForwardRef can be used instead of strings Content = Union[ - "Binning", - "MultiBinning", - "Category", - "Formula", - "FormulaRef", - "Transform", - "HashPRNG", + Annotated[ + Union[ + "Binning", + "MultiBinning", + "Category", + "Formula", + "FormulaRef", + "Transform", + "HashPRNG", + ], + Field(discriminator="nodetype"), + ], float, ]