Skip to content

Commit

Permalink
Use == False instead of is False, restrict allowed values for EnableV…
Browse files Browse the repository at this point in the history
…ariable
  • Loading branch information
bengineerd committed Jan 8, 2025
1 parent bd5f1f2 commit 2f19ffc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyrogue/_DataReceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _acceptFrame(self, frame):
"""
# Do nothing if not yet started or enabled
if self.running is False or self.RxEnable.value() is False:
if self.running is False or self.RxEnable.value() == False:
return

# Lock frame
Expand Down
6 changes: 6 additions & 0 deletions python/pyrogue/_Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def __init__(self, *, enabled, deps=None):
groups='Enable',
disp={False: 'False', True: 'True', 'parent': 'ParentFalse', 'deps': 'ExtDepFalse'})

self.allowed_values = {True, False, 'parent', 'deps'}

if deps is None:
self._deps = []
self._depDis = False
Expand Down Expand Up @@ -97,6 +99,10 @@ def set(self, value, write=True, index=-1):
-------
"""
if value not in self.allowed_values:
raise pr.VariableError(
f'Error calling {self.path}.set({value=}) - value must be one of {self.allowed_values}')

if value != 'parent' and value != 'deps':
old = self.value()

Expand Down

0 comments on commit 2f19ffc

Please sign in to comment.