To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 69d4a7a6 authored by mikolajr's avatar mikolajr
Browse files

In PfeifferTPG device: fix type check errors

parent 5a4d493f
......@@ -15,9 +15,16 @@ from typing import List, Union, Tuple
from .base import SingleCommDevice
from ..comm import SerialCommunication, SerialCommunicationConfig
from ..comm.serial import (
SerialCommunicationParity,
SerialCommunicationStopbits,
SerialCommunicationBytesize,
)
from ..configuration import configdataclass
from ..utils.enum import NameEnum
Number = Union[int, float]
@configdataclass
class PfeifferTPGSerialCommunicationConfig(SerialCommunicationConfig):
......@@ -25,22 +32,25 @@ class PfeifferTPGSerialCommunicationConfig(SerialCommunicationConfig):
baudrate: int = 9600
#: Pfeiffer TPG controllers do not use parity
parity: (str, SerialCommunicationConfig.Parity) = \
SerialCommunicationConfig.Parity.NONE
parity: Union[
str, SerialCommunicationParity
] = SerialCommunicationParity.NONE
#: Pfeiffer TPG controllers use one stop bit
stopbits: (int, SerialCommunicationConfig.Stopbits) = \
SerialCommunicationConfig.Stopbits.ONE
stopbits: Union[
int, SerialCommunicationStopbits
] = SerialCommunicationStopbits.ONE
#: One byte is eight bits long
bytesize: (int, SerialCommunicationConfig.Bytesize) = \
SerialCommunicationConfig.Bytesize.EIGHTBITS
bytesize: Union[
int, SerialCommunicationBytesize
] = SerialCommunicationBytesize.EIGHTBITS
#: The terminator is <CR><LF>
terminator: bytes = b'\r\n'
#: use 3 seconds timeout as default
timeout: (int, float) = 3
timeout: Number = 3
class PfeifferTPGSerialCommunication(SerialCommunication):
......@@ -129,7 +139,9 @@ class PfeifferTPGConfig:
# model of the TPG (determines which lookup table to use for the
# full scale range)
model: (str, Model) = Model.TPG25xA
model: Union[
str, Model
] = Model.TPG25xA # type: ignore
def clean_values(self):
if not isinstance(self.model, self.Model):
......@@ -156,7 +168,7 @@ class PfeifferTPG(SingleCommDevice):
hPascal = 4
Volt = 5
SensorTypes = Enum(
SensorTypes = Enum( # type: ignore
value='SensorTypes',
names=[
('TPR/PCR Pirani Gauge', 1),
......@@ -270,7 +282,7 @@ class PfeifferTPG(SingleCommDevice):
# identification successful:
logging.info(f"Identified {self}")
def set_display_unit(self, unit: (str, PressureUnits)) -> None:
def set_display_unit(self, unit: Union[str, PressureUnits]) -> None:
"""
Set the unit in which the measurements are shown on the display.
......@@ -406,7 +418,7 @@ class PfeifferTPG(SingleCommDevice):
logging.info(f"Obtained full scale range of all sensors as {fsr}.")
return fsr
def set_full_scale_mbar(self, fsr: List[Union[int, float]]) -> None:
def set_full_scale_mbar(self, fsr: List[Number]) -> None:
"""
Set the full scale range of the attached sensors (in unit mbar)
......@@ -435,7 +447,7 @@ class PfeifferTPG(SingleCommDevice):
logging.error("Setting sensors full scale range failed.")
raise
def get_full_scale_mbar(self) -> List[Union[int, float]]:
def get_full_scale_mbar(self) -> List[Number]:
"""
Get the full scale range of the attached sensors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment