|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 |
|
4 |
| -from typing import Optional, List, Union |
| 4 | +from typing import Optional, List, Union, Tuple |
5 | 5 | from dataclasses import dataclass, field, InitVar
|
6 | 6 | from pathlib import Path
|
7 | 7 | from wireviz.wv_helper import int2tuple, aspect_ratio
|
|
19 | 19 | Color = str # Two-letter color name = Literal[wv_colors._color_hex.keys()]
|
20 | 20 | Colors = str # One or more two-letter color names (Color) concatenated into one string
|
21 | 21 | ColorScheme = str # Color scheme name = Literal[wv_colors.COLOR_CODES.keys()]
|
| 22 | +NoneOrMorePins = Union[Pin, Tuple[Pin, ...], None] # None, one, or a tuple of pins |
| 23 | +OneOrMoreWires = Union[Wire, Tuple[Wire, ...]] # One or a tuple of wires |
22 | 24 |
|
23 | 25 |
|
24 | 26 | @dataclass
|
@@ -96,7 +98,7 @@ class Connector:
|
96 | 98 | ignore_in_bom: bool = False
|
97 | 99 | additional_components: List[AdditionalComponent] = field(default_factory=list)
|
98 | 100 |
|
99 |
| - def __post_init__(self): |
| 101 | + def __post_init__(self) -> None: |
100 | 102 |
|
101 | 103 | if isinstance(self.image, dict):
|
102 | 104 | self.image = Image(**self.image)
|
@@ -148,7 +150,7 @@ def __post_init__(self):
|
148 | 150 | if isinstance(item, dict):
|
149 | 151 | self.additional_components[i] = AdditionalComponent(**item)
|
150 | 152 |
|
151 |
| - def activate_pin(self, pin): |
| 153 | + def activate_pin(self, pin: Pin) -> None: |
152 | 154 | self.visible_pins[pin] = True
|
153 | 155 |
|
154 | 156 | def get_qty_multiplier(self, qty_multiplier: Optional[ConnectorMultiplier]) -> int:
|
@@ -186,7 +188,7 @@ class Cable:
|
186 | 188 | ignore_in_bom: bool = False
|
187 | 189 | additional_components: List[AdditionalComponent] = field(default_factory=list)
|
188 | 190 |
|
189 |
| - def __post_init__(self): |
| 191 | + def __post_init__(self) -> None: |
190 | 192 |
|
191 | 193 | if isinstance(self.image, dict):
|
192 | 194 | self.image = Image(**self.image)
|
@@ -246,7 +248,9 @@ def __post_init__(self):
|
246 | 248 | if isinstance(item, dict):
|
247 | 249 | self.additional_components[i] = AdditionalComponent(**item)
|
248 | 250 |
|
249 |
| - def connect(self, from_name, from_pin, via_pin, to_name, to_pin): |
| 251 | + # The *_pin arguments accept a tuple, but it seems not in use with the current code. |
| 252 | + def connect(self, from_name: Optional[Designator], from_pin: NoneOrMorePins, via_pin: OneOrMoreWires, |
| 253 | + to_name: Optional[Designator], to_pin: NoneOrMorePins) -> None: |
250 | 254 | from_pin = int2tuple(from_pin)
|
251 | 255 | via_pin = int2tuple(via_pin)
|
252 | 256 | to_pin = int2tuple(to_pin)
|
|
0 commit comments