Fix PyLance problems
This commit is contained in:
parent
271fb13a07
commit
310e5968ef
@ -393,7 +393,7 @@ def parse(
|
|||||||
return tuple(returns) if len(returns) != 1 else returns[0]
|
return tuple(returns) if len(returns) != 1 else returns[0]
|
||||||
|
|
||||||
|
|
||||||
def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
|
def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> Tuple[Dict, Path]:
|
||||||
# determine whether inp is a file path, a YAML string, or a Dict
|
# determine whether inp is a file path, a YAML string, or a Dict
|
||||||
if not isinstance(inp, Dict): # received a str or a Path
|
if not isinstance(inp, Dict): # received a str or a Path
|
||||||
if isinstance(inp, Path) or (isinstance(inp, str) and not "\n" in inp):
|
if isinstance(inp, Path) or (isinstance(inp, str) and not "\n" in inp):
|
||||||
|
|||||||
@ -186,7 +186,7 @@ class MultiColor:
|
|||||||
elif len(self) == 3:
|
elif len(self) == 3:
|
||||||
out = [color.html for color in self.colors]
|
out = [color.html for color in self.colors]
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Padding not supported for len {len(selfq)}")
|
raise Exception(f"Padding not supported for len {len(self)}")
|
||||||
return [str(color) for color in out]
|
return [str(color) for color in out]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -82,8 +82,8 @@ class Options:
|
|||||||
template_separator: str = "."
|
template_separator: str = "."
|
||||||
_pad: int = 0
|
_pad: int = 0
|
||||||
# TODO: resolve template and image paths during rendering, not during YAML parsing
|
# TODO: resolve template and image paths during rendering, not during YAML parsing
|
||||||
_template_paths: [List] = field(default_factory=list)
|
_template_paths: List = field(default_factory=list)
|
||||||
_image_paths: [List] = field(default_factory=list)
|
_image_paths: List = field(default_factory=list)
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
|
|
||||||
@ -759,9 +759,9 @@ class Cable(TopLevelGraphicalComponent):
|
|||||||
|
|
||||||
def _connect(
|
def _connect(
|
||||||
self,
|
self,
|
||||||
from_pin_obj: [PinClass],
|
from_pin_obj: List[PinClass],
|
||||||
via_wire_id: str,
|
via_wire_id: str,
|
||||||
to_pin_obj: [PinClass],
|
to_pin_obj: List[PinClass],
|
||||||
) -> None:
|
) -> None:
|
||||||
via_wire_obj = self.wire_objects[via_wire_id]
|
via_wire_obj = self.wire_objects[via_wire_id]
|
||||||
self._connections.append(Connection(from_pin_obj, via_wire_obj, to_pin_obj))
|
self._connections.append(Connection(from_pin_obj, via_wire_obj, to_pin_obj))
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
from typing import Any, List, Optional, Union
|
from typing import Any, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from wireviz import APP_NAME, APP_URL, __version__
|
from wireviz import APP_NAME, APP_URL, __version__
|
||||||
from wireviz.wv_bom import partnumbers2list
|
from wireviz.wv_bom import partnumbers2list
|
||||||
@ -347,7 +347,7 @@ def gv_wire_cell(wire: Union[WireClass, ShieldClass], colspan: int) -> Td:
|
|||||||
return wire_outer_cell
|
return wire_outer_cell
|
||||||
|
|
||||||
|
|
||||||
def gv_edge_wire(harness, cable, connection) -> (str, str, str):
|
def gv_edge_wire(harness, cable, connection) -> Tuple[str, str, str, str, str]:
|
||||||
if connection.via.color:
|
if connection.via.color:
|
||||||
# check if it's an actual wire and not a shield
|
# check if it's an actual wire and not a shield
|
||||||
color = f"#000000:{connection.via.color.html_padded}:#000000"
|
color = f"#000000:{connection.via.color.html_padded}:#000000"
|
||||||
@ -391,7 +391,7 @@ def parse_arrow_str(inp: str) -> ArrowDirection:
|
|||||||
return ArrowDirection.NONE
|
return ArrowDirection.NONE
|
||||||
|
|
||||||
|
|
||||||
def gv_edge_mate(mate) -> (str, str, str, str):
|
def gv_edge_mate(mate) -> Tuple[str, str, str, str]:
|
||||||
if mate.arrow.weight == ArrowWeight.SINGLE:
|
if mate.arrow.weight == ArrowWeight.SINGLE:
|
||||||
color = "#000000"
|
color = "#000000"
|
||||||
elif mate.arrow.weight == ArrowWeight.DOUBLE:
|
elif mate.arrow.weight == ArrowWeight.DOUBLE:
|
||||||
@ -448,7 +448,7 @@ def color_minitable(color: Optional[MultiColor]) -> Union[Table, str]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def image_and_caption_cells(component: Component) -> (Td, Td):
|
def image_and_caption_cells(component: Component) -> Tuple[Td, Td]:
|
||||||
if not component.image:
|
if not component.image:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List, Union
|
||||||
|
|
||||||
from graphviz import Graph
|
from graphviz import Graph
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ from wireviz.wv_graphviz import (
|
|||||||
parse_arrow_str,
|
parse_arrow_str,
|
||||||
set_dot_basics,
|
set_dot_basics,
|
||||||
)
|
)
|
||||||
from wireviz.wv_output import embed_svg_images_file, generate_html_output
|
from wireviz.wv_output import embed_svg_images, embed_svg_images_file, generate_html_output
|
||||||
from wireviz.wv_utils import bom2tsv, open_file_write
|
from wireviz.wv_utils import bom2tsv, open_file_write
|
||||||
|
|
||||||
|
|
||||||
@ -210,11 +210,11 @@ class Harness:
|
|||||||
def connect(
|
def connect(
|
||||||
self,
|
self,
|
||||||
from_name: str,
|
from_name: str,
|
||||||
from_pin: (int, str),
|
from_pin: Union[int, str],
|
||||||
via_name: str,
|
via_name: str,
|
||||||
via_wire: (int, str),
|
via_wire: Union[int, str],
|
||||||
to_name: str,
|
to_name: str,
|
||||||
to_pin: (int, str),
|
to_pin: Union[int, str],
|
||||||
) -> None:
|
) -> None:
|
||||||
# check from and to connectors
|
# check from and to connectors
|
||||||
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]):
|
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]):
|
||||||
@ -381,7 +381,7 @@ class Harness:
|
|||||||
|
|
||||||
def output(
|
def output(
|
||||||
self,
|
self,
|
||||||
filename: (str, Path),
|
filename: Union[str, Path],
|
||||||
view: bool = False,
|
view: bool = False,
|
||||||
cleanup: bool = True,
|
cleanup: bool = True,
|
||||||
fmt: tuple = ("html", "png", "svg", "tsv"),
|
fmt: tuple = ("html", "png", "svg", "tsv"),
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
awg_equiv_table = {
|
awg_equiv_table = {
|
||||||
"0.09": "28",
|
"0.09": "28",
|
||||||
@ -159,7 +159,7 @@ def aspect_ratio(image_src):
|
|||||||
return 1 # Assume 1:1 when unable to read actual image size
|
return 1 # Assume 1:1 when unable to read actual image size
|
||||||
|
|
||||||
|
|
||||||
def smart_file_resolve(filename: str, possible_paths: (str, List[str])) -> Path:
|
def smart_file_resolve(filename: str, possible_paths: Union[str, List[str]]) -> Path:
|
||||||
if not isinstance(possible_paths, List):
|
if not isinstance(possible_paths, List):
|
||||||
possible_paths = [possible_paths]
|
possible_paths = [possible_paths]
|
||||||
filename = Path(filename)
|
filename = Path(filename)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user