Skip to content

Commit

Permalink
Add type annotation of methods too
Browse files Browse the repository at this point in the history
  • Loading branch information
kvid committed Sep 8, 2020
1 parent 08cd97b commit 69b657d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Connector:
autogenerate: bool = False
loops: List[List[Pin]] = field(default_factory=list)

def __post_init__(self):
def __post_init__(self) -> None:
self.ports_left = False
self.ports_right = False
self.visible_pins = {}
Expand Down Expand Up @@ -81,7 +81,7 @@ def __post_init__(self):
if len(loop) != 2:
raise Exception('Loops must be between exactly two pins!')

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


Expand All @@ -106,7 +106,7 @@ class Cable:
show_name: bool = True
show_wirecount: bool = True

def __post_init__(self):
def __post_init__(self) -> None:

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


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

0 comments on commit 69b657d

Please sign in to comment.