Skip to content

Commit

Permalink
Update type hints
Browse files Browse the repository at this point in the history
as suggested by @kvid.

Co-authored-by: kvid <kvid@users.noreply.github.com>
  • Loading branch information
17o2 and kvid committed Aug 22, 2021
1 parent 4fef57b commit b06ae96
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
# Type combinations
Colors = PlainText # One or more two-letter color names (Color) concatenated into one string
Pin = Union[int, PlainText] # Pin identifier
PinIndex = int # Zero-based pin index
Wire = Union[int, PlainText] # Wire number or Literal['s'] for shield
NoneOrMorePins = Union[Pin, Tuple[Pin, ...], None] # None, one, or a tuple of pins
NoneOrMorePinIndices = Union[PinIndex, Tuple[PinIndex, ...], None] # None, one, or a tuple of zero-based pin indices
OneOrMoreWires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires


Expand Down Expand Up @@ -277,8 +278,8 @@ def __post_init__(self) -> None:
self.additional_components[i] = AdditionalComponent(**item)

# The *_pin arguments accept a tuple, but it seems not in use with the current code.
def connect(self, from_name: Optional[Designator], from_pin: NoneOrMorePins, via_wire: OneOrMoreWires,
to_name: Optional[Designator], to_pin: NoneOrMorePins) -> None:
def connect(self, from_name: Optional[Designator], from_pin: NoneOrMorePinIndices, via_wire: OneOrMoreWires,
to_name: Optional[Designator], to_pin: NoneOrMorePinIndices) -> None:
from_pin = int2tuple(from_pin)
via_wire = int2tuple(via_wire)
to_pin = int2tuple(to_pin)
Expand All @@ -305,7 +306,7 @@ def get_qty_multiplier(self, qty_multiplier: Optional[CableMultiplier]) -> float
@dataclass
class Connection:
from_name: Optional[Designator]
from_port: Optional[Pin]
from_port: Optional[PinIndex]
via_port: Wire
to_name: Optional[Designator]
to_port: Optional[Pin]
to_port: Optional[PinIndex]

0 comments on commit b06ae96

Please sign in to comment.