Skip to content

Commit

Permalink
Merge pull request #961 from slaclab/check_types
Browse files Browse the repository at this point in the history
Use isinstance to check types in variable representation
  • Loading branch information
slacrherbst authored Aug 8, 2023
2 parents 4a7a738 + fa79e3f commit 62e41dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions python/pyrogue/_HelperFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ def _var_representer(dumper, data):
-------
"""
if type(data.value) == bool:
if isinstance(data.value, bool):
enc = 'tag:yaml.org,2002:bool'
elif data.enum is not None:
enc = 'tag:yaml.org,2002:str'
elif type(data.value) == int:
elif isinstance(data.value, int):
enc = 'tag:yaml.org,2002:int'
elif type(data.value) == float:
elif isinstance(data.value, float):
enc = 'tag:yaml.org,2002:float'
else:
enc = 'tag:yaml.org,2002:str'
Expand Down
2 changes: 1 addition & 1 deletion python/pyrogue/_Variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def __init__(self, *,
self._enum = disp
elif isinstance(disp, list):
self._enum = {k:str(k) for k in disp}
elif type(value) == bool and enum is None:
elif isinstance(value, bool) and enum is None:
self._enum = {False: 'False', True: 'True'}

if self._enum is not None:
Expand Down

0 comments on commit 62e41dc

Please sign in to comment.