From 74916a66d8021234d23c0cbd51bd0748c2d99636 Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Sun, 5 Jun 2022 15:35:36 +0200 Subject: [PATCH] Type hinting --- projector.py | 8 +++++--- serialdevice.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/projector.py b/projector.py index 09f17cf..8a94bd7 100644 --- a/projector.py +++ b/projector.py @@ -11,15 +11,17 @@ class ProjectorSerial(SerialDevice): super().__init__(serial_port, baudrate) - def send_command(self, command: str, verbose: bool = False, device_id: str = "ZZ"): + def send_command( + self, command: str, verbose: bool = False, device_id: str = "ZZ" + ) -> str: assert device_id in ["01", "02", "03", "04", "05", "06", "ZZ"] full_command = f"\x02AD{device_id};{command}\x03" return super().send_command(full_command, verbose) - def power_on(self): + def power_on(self) -> None: self.send_command("PON") - def power_off(self): + def power_off(self) -> None: self.send_command("POF") diff --git a/serialdevice.py b/serialdevice.py index d568046..b8ef89f 100644 --- a/serialdevice.py +++ b/serialdevice.py @@ -7,7 +7,7 @@ class SerialDevice: self.serial_port: str = serial_port self.baudrate = baudrate - def send_command(self, command: str, verbose: bool = False): + def send_command(self, command: str, verbose: bool = False) -> str: with Serial(self.serial_port, self.baudrate, timeout=1) as s: if verbose: print("Send:", command)