1717# @author [email protected] (Alan Smith) 1818from abc import ABC , abstractmethod
1919from enum import Enum
20- from typing import Self
20+ from typing import Final , Self
2121
22- _base_compound = 256
22+ _BASE_COMPOUND : Final [ int ] = 256
2323
2424class PortType (Enum ):
2525 # Ports on the SystemCore.
@@ -35,9 +35,9 @@ class PortType(Enum):
3535 EXPANSION_HUB_SERVO_PORT = 8 # A servo port on an expansion hub.
3636
3737 # Compound ports
38- USB_HUB = _base_compound + 1 # A compound port with USB_PORT and USB_HUB_PORT.
39- EXPANSION_HUB_MOTOR = _base_compound + 2 # A compound port with USB_PORT and EXPANSION_HUB_MOTOR_PORT.
40- EXPANSION_HUB_SERVO = _base_compound + 3 # A compound port with USB_PORT and EXPANSION_HUB_SERVO_PORT.
38+ USB_HUB = _BASE_COMPOUND + 1 # A compound port with USB_PORT and USB_HUB_PORT.
39+ EXPANSION_HUB_MOTOR = _BASE_COMPOUND + 2 # A compound port with USB_PORT and EXPANSION_HUB_MOTOR_PORT.
40+ EXPANSION_HUB_SERVO = _BASE_COMPOUND + 3 # A compound port with USB_PORT and EXPANSION_HUB_SERVO_PORT.
4141
4242class Port (ABC ):
4343 """Abstract base class for all port types."""
@@ -63,7 +63,7 @@ def __init__(self, port_type: PortType, location: int):
6363 port_type: PortType for this port (must be a simple type)
6464 location: int location for this port
6565 """
66- if port_type .value >= _base_compound :
66+ if port_type .value >= _BASE_COMPOUND :
6767 raise ValueError ("Port must be of a simple type" )
6868 super ().__init__ (port_type )
6969 self .location = location
@@ -85,7 +85,7 @@ def __init__(self, port_type: PortType, port1: Port, port2: Port):
8585 port1: First Port for compound ports
8686 port2: Second Port for compound ports
8787 """
88- if port_type .value < _base_compound :
88+ if port_type .value < _BASE_COMPOUND :
8989 raise ValueError ("Port must be of a compound type" )
9090 super ().__init__ (port_type )
9191 self .port1 = port1
0 commit comments