Skip to content

Commit fbcae68

Browse files
committed
Add type annotation of methods too
1 parent 9fb84c6 commit fbcae68

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/wireviz/DataClasses.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Connector:
3737
autogenerate: bool = False
3838
loops: List[List[Pin]] = field(default_factory=list)
3939

40-
def __post_init__(self):
40+
def __post_init__(self) -> None:
4141
self.ports_left = False
4242
self.ports_right = False
4343
self.visible_pins = {}
@@ -81,7 +81,7 @@ def __post_init__(self):
8181
if len(loop) != 2:
8282
raise Exception('Loops must be between exactly two pins!')
8383

84-
def activate_pin(self, pin):
84+
def activate_pin(self, pin: Pin) -> None:
8585
self.visible_pins[pin] = True
8686

8787

@@ -106,7 +106,7 @@ class Cable:
106106
show_name: bool = True
107107
show_wirecount: bool = True
108108

109-
def __post_init__(self):
109+
def __post_init__(self) -> None:
110110

111111
if isinstance(self.gauge, str): # gauge and unit specified
112112
try:
@@ -160,7 +160,10 @@ def __post_init__(self):
160160
raise Exception('lists of part data are only supported for bundles')
161161

162162

163-
def connect(self, from_name, from_pin, via_pin, to_name, to_pin):
163+
# Pins = Union[Pin, Tuple[Pin, ...], None] # None, one, or a tuple of pins
164+
# Wires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires
165+
# The *_pin arguments also accept a tuple, but it seems not in use with the current code.
166+
def connect(self, from_name: Optional[Name], from_pin: Optional[Pin], via_pin: Wire, to_name: Optional[Name], to_pin: Optional[Pin]) -> None:
164167
from_pin = int2tuple(from_pin)
165168
via_pin = int2tuple(via_pin)
166169
to_pin = int2tuple(to_pin)

0 commit comments

Comments
 (0)