Skip to content

Commit

Permalink
fix bug w custom ruamel yaml types
Browse files Browse the repository at this point in the history
  • Loading branch information
dhpitt committed May 1, 2024
1 parent afa3f6f commit c4e6f5a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/configmypy/type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c4e6f5a

Please sign in to comment.