Skip to content

Commit

Permalink
Tweak sensor value setter logic for core.Address
Browse files Browse the repository at this point in the history
I'd missed it in the previous update.

Contributes to: NGC-1062.
  • Loading branch information
amishatishpatel committed Aug 14, 2024
1 parent f6d3a3d commit 7732511
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/aiokatcp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ def _check_value_type(self, value: _T) -> _T:
"""

if isinstance(value, self._core_type) and not issubclass(self._core_type, enum.Enum):
# The more general case of e.g. numpy types not being directly
# comparable with python types.
return value
elif self.stype is core.Timestamp and isinstance(value, numbers.Real):
# core.Timestamp can also be a float
return value # type: ignore
elif type(value) in [bytes, str, core.Address] and self.stype is core.Address:
return core.Address(value) # type: ignore
elif isinstance(value, self.stype):
# To ensure specific types of enum.Enums are handled correctly
return value
else:
raise TypeError(
Expand Down

0 comments on commit 7732511

Please sign in to comment.