From c4e6f5ade2f9e081d4f1e4b05adf363dcd611b55 Mon Sep 17 00:00:00 2001 From: dhpitt Date: Wed, 1 May 2024 14:42:32 -0700 Subject: [PATCH] fix bug w custom ruamel yaml types --- src/configmypy/type_inference.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/configmypy/type_inference.py b/src/configmypy/type_inference.py index 9774215..ee07ce5 100644 --- a/src/configmypy/type_inference.py +++ b/src/configmypy/type_inference.py @@ -6,6 +6,9 @@ # import custom Yaml types to handle sequences from ruamel.yaml import CommentedSeq, CommentedMap +from ruamel.yaml.scalarfloat import ScalarFloat +from ruamel.yaml.scalarint import ScalarInt +from ruamel.yaml.scalarbool import ScalarBoolean def infer_boolean(var, strict: bool=True): @@ -117,9 +120,9 @@ def __call__(self, var): var: original variable (any type) """ - if self.orig_type == bool: + if self.orig_type == bool or self.orig_type == ScalarBoolean: return infer_boolean(var, self.strict) - elif self.orig_type == float or self.orig_type == int: + elif self.orig_type == float or self.orig_type == int or self.orig_type == ScalarFloat or self.orig_type == ScalarInt: return infer_numeric(var, self.strict) elif self.orig_type == tuple or self.orig_type == list or self.orig_type == CommentedMap or self.orig_type == CommentedSeq: return infer_iterable(var, None, self.strict)