Island: Add ConnectionTarget TypeAlias

This commit is contained in:
Mike Salvatore 2022-09-06 08:33:17 -04:00
parent 3b2954ec02
commit b33fd7f436
2 changed files with 4 additions and 4 deletions

View File

@ -11,5 +11,5 @@ from .simulation import Simulation, SimulationSchema, IslandMode
from .user_credentials import UserCredentials from .user_credentials import UserCredentials
from .machine import Machine, MachineID from .machine import Machine, MachineID
from .communication_type import CommunicationType from .communication_type import CommunicationType
from .node import Node from .node import Node, ConnectionTarget
from .agent import Agent, AgentID from .agent import Agent, AgentID

View File

@ -1,4 +1,4 @@
from typing import Sequence, Tuple from typing import Collection, Sequence, Tuple, TypeAlias
from pydantic import Field, validator from pydantic import Field, validator
@ -7,12 +7,12 @@ from common.transforms import make_immutable_nested_sequence
from . import CommunicationType, MachineID from . import CommunicationType, MachineID
ConnectionsSequence = Sequence[Tuple[MachineID, Sequence[CommunicationType]]] ConnectionTarget: TypeAlias = Tuple[MachineID, Sequence[CommunicationType]]
class Node(MutableInfectionMonkeyBaseModel): class Node(MutableInfectionMonkeyBaseModel):
machine_id: MachineID = Field(..., allow_mutation=False) machine_id: MachineID = Field(..., allow_mutation=False)
connections: ConnectionsSequence connections: Collection[ConnectionTarget]
_make_immutable_nested_sequence = validator("connections", pre=True, allow_reuse=True)( _make_immutable_nested_sequence = validator("connections", pre=True, allow_reuse=True)(
make_immutable_nested_sequence make_immutable_nested_sequence