1- from typing import List , Optional , Tuple
1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING , List , Optional , Tuple
24
35from yaramo .base_element import BaseElement
46from yaramo .geo_node import GeoNode
57from yaramo .node import Node
68from yaramo .vacancy_section import VacancySection
79
10+ if TYPE_CHECKING :
11+ from yaramo .signal import Signal , SignalDirection
12+
813
914class Edge (BaseElement ):
1015 """This class is one of two Elements (Edge and Node) comprising the base of the yaramo Topology.
@@ -22,7 +27,7 @@ def __init__(
2227 vacancy_section : Optional [VacancySection ] = None ,
2328 length : float = None ,
2429 intermediate_geo_nodes : List [GeoNode ] = None ,
25- signals : list [" Signal" ] = None ,
30+ signals : list [Signal ] = None ,
2631 maximum_speed : int = None ,
2732 ** kwargs
2833 ):
@@ -86,7 +91,7 @@ def __get_length(self) -> float:
8691 )
8792 return total_length
8893
89- def get_direction_based_on_start_node (self , start : " Node" ) -> " SignalDirection" :
94+ def get_direction_based_on_start_node (self , start : Node ) -> SignalDirection :
9095 from yaramo .signal import SignalDirection
9196
9297 if self .node_a .uuid == start .uuid :
@@ -95,7 +100,7 @@ def get_direction_based_on_start_node(self, start: "Node") -> "SignalDirection":
95100 return SignalDirection .GEGEN
96101 return None
97102
98- def get_direction_based_on_nodes (self , node_a : " Node" , node_b : " Node" ) -> " SignalDirection" :
103+ def get_direction_based_on_nodes (self , node_a : Node , node_b : Node ) -> SignalDirection :
99104 """Returns the direction according to whether the order of node_a and node_b is the same as in self
100105
101106 Parameters
@@ -119,7 +124,7 @@ def get_direction_based_on_nodes(self, node_a: "Node", node_b: "Node") -> "Signa
119124 return SignalDirection .GEGEN
120125 return None
121126
122- def get_signals_with_direction_in_order (self , direction : " SignalDirection" ) -> List [" Signal" ]:
127+ def get_signals_with_direction_in_order (self , direction : SignalDirection ) -> List [Signal ]:
123128 """Returns all the signals (with that direction) on that Edge ordered by the given direction
124129
125130 This only consideres Signals of SignalFunction type Einfahr_Signal, Ausfahr_Signal and Block_Signal that have the same direction as requested.
@@ -150,7 +155,7 @@ def get_signals_with_direction_in_order(self, direction: "SignalDirection") -> L
150155 result .sort (key = lambda x : x .distance_edge , reverse = (direction == SignalDirection .GEGEN ))
151156 return result
152157
153- def get_opposite_node (self , node : " Node" ) -> " Node" :
158+ def get_opposite_node (self , node : Node ) -> Node :
154159 """Returns the opposite Node of the given Node
155160
156161 Parameters
@@ -168,7 +173,7 @@ def get_opposite_node(self, node: "Node") -> "Node":
168173 return self .node_b
169174 return self .node_a
170175
171- def get_next_geo_node (self , node : " Node" ) -> " GeoNode" :
176+ def get_next_geo_node (self , node : Node ) -> GeoNode :
172177 """Returns the next GeoNode on Edgeof the given Top Node
173178
174179 Parameters
0 commit comments