Fix PyLance problems

This commit is contained in:
Daniel Rojas 2023-03-27 13:20:39 +02:00 committed by KV
parent 271fb13a07
commit 310e5968ef
6 changed files with 18 additions and 18 deletions

View File

@ -393,7 +393,7 @@ def parse(
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
if not isinstance(inp, Dict): # received a str or a Path
if isinstance(inp, Path) or (isinstance(inp, str) and not "\n" in inp):

View File

@ -186,7 +186,7 @@ class MultiColor:
elif len(self) == 3:
out = [color.html for color in self.colors]
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]
@property

View File

@ -82,8 +82,8 @@ class Options:
template_separator: str = "."
_pad: int = 0
# TODO: resolve template and image paths during rendering, not during YAML parsing
_template_paths: [List] = field(default_factory=list)
_image_paths: [List] = field(default_factory=list)
_template_paths: List = field(default_factory=list)
_image_paths: List = field(default_factory=list)
def __post_init__(self):
@ -759,9 +759,9 @@ class Cable(TopLevelGraphicalComponent):
def _connect(
self,
from_pin_obj: [PinClass],
from_pin_obj: List[PinClass],
via_wire_id: str,
to_pin_obj: [PinClass],
to_pin_obj: List[PinClass],
) -> None:
via_wire_obj = self.wire_objects[via_wire_id]
self._connections.append(Connection(from_pin_obj, via_wire_obj, to_pin_obj))

View File

@ -2,7 +2,7 @@
import re
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.wv_bom import partnumbers2list
@ -347,7 +347,7 @@ def gv_wire_cell(wire: Union[WireClass, ShieldClass], colspan: int) -> Td:
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:
# check if it's an actual wire and not a shield
color = f"#000000:{connection.via.color.html_padded}:#000000"
@ -391,7 +391,7 @@ def parse_arrow_str(inp: str) -> ArrowDirection:
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:
color = "#000000"
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:
return (None, None)

View File

@ -3,7 +3,7 @@
from collections import defaultdict
from dataclasses import dataclass, field
from pathlib import Path
from typing import List
from typing import List, Union
from graphviz import Graph
@ -35,7 +35,7 @@ from wireviz.wv_graphviz import (
parse_arrow_str,
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
@ -210,11 +210,11 @@ class Harness:
def connect(
self,
from_name: str,
from_pin: (int, str),
from_pin: Union[int, str],
via_name: str,
via_wire: (int, str),
via_wire: Union[int, str],
to_name: str,
to_pin: (int, str),
to_pin: Union[int, str],
) -> None:
# check from and to connectors
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]):
@ -381,7 +381,7 @@ class Harness:
def output(
self,
filename: (str, Path),
filename: Union[str, Path],
view: bool = False,
cleanup: bool = True,
fmt: tuple = ("html", "png", "svg", "tsv"),

View File

@ -2,7 +2,7 @@
import re
from pathlib import Path
from typing import List, Optional
from typing import List, Optional, Union
awg_equiv_table = {
"0.09": "28",
@ -159,7 +159,7 @@ def aspect_ratio(image_src):
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):
possible_paths = [possible_paths]
filename = Path(filename)