Skip to content

Commit

Permalink
Fix some type hints and add default case (raise exception) for invali…
Browse files Browse the repository at this point in the history
…d relay state values
  • Loading branch information
ylabonte committed Aug 21, 2024
1 parent a2ec897 commit db3df91
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/proconip/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def _relay_state(self) -> str:
return "Off"
case 3:
return "On"
case _:
raise ValueError(f"Unexpected value {self._value}")

@property
def name(self) -> str:
Expand Down Expand Up @@ -424,9 +426,9 @@ def get_dosage_relay(self, data_entity) -> int:

def is_dosage_relay(
self,
relay_object: Relay = None,
data_object: DataObject = None,
relay_id: int = None,
relay_object: Relay | None = None,
data_object: DataObject | None = None,
relay_id: int | None = None,
) -> bool:
"""Returns true if the given relay_object OR data_object OR column refers to a dosage
control relay."""
Expand Down Expand Up @@ -657,7 +659,7 @@ def get_relays(self) -> list[Relay]:
"""Returns a list of all relays as Relay instances."""
return self.relays() + self.external_relays()

def determine_overall_relay_bit_state(self) -> [int, int]:
def determine_overall_relay_bit_state(self) -> list[int]:
"""Determine the overall relay a bit state from the current state."""
relays = self.relays()
bit_state = [255, 0]
Expand Down

0 comments on commit db3df91

Please sign in to comment.