Skip to content

Commit c2a4aab

Browse files
committed
Changed _base_compound to _BASE_COMPOUND.
1 parent e4cd9e2 commit c2a4aab

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

external_samples/port.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
# @author [email protected] (Alan Smith)
1818
from abc import ABC, abstractmethod
1919
from 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

2424
class 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

4242
class 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

Comments
 (0)