Skip to content

Commit 60d90ab

Browse files
committed
almost there?
1 parent 3282922 commit 60d90ab

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

edg/core/PortBlocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def Port(self, tpe: T, *args: Any, **kwargs: Any) -> T:
3838
return super().Port(tpe, *args, optional=True, **kwargs)
3939

4040

41-
AdapterDstType = TypeVar('AdapterDstType', bound=Port)
41+
AdapterDstType = TypeVar('AdapterDstType', covariant=True, bound=Port, default=Port)
4242
@abstract_block
4343
class PortAdapter(InternalBlock, Block, Generic[AdapterDstType]):
4444
"""Defines an adapter from one port type to another port type. This behaves as a normal block, and both the src and

edg/electronics_model/CircuitBlock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def contents(self) -> None:
115115
self.net()
116116

117117

118-
AdapterDstType = TypeVar('AdapterDstType', bound='CircuitPort')
118+
AdapterDstType = TypeVar('AdapterDstType', covariant=True, bound='CircuitPort', default='CircuitPort')
119119
@abstract_block
120120
class CircuitPortAdapter(KiCadImportableBlock, NetBaseBlock, PortAdapter[AdapterDstType], Generic[AdapterDstType]):
121121
def symbol_pinning(self, symbol_name: str) -> Dict[str, BasePort]:

edg/electronics_model/ConnectedGenerator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class DefaultConnectionBlock(InternalBlock):
1616
pass
1717

1818

19-
OutputType = TypeVar('OutputType', bound=Port)
20-
InputsType = TypeVar('InputsType', bound=Port)
21-
LinkType = TypeVar('LinkType', bound=Link)
19+
OutputType = TypeVar('OutputType', covariant=True, bound=Port, default=Port)
20+
InputsType = TypeVar('InputsType', covariant=True, bound=Port, default=Port)
21+
LinkType = TypeVar('LinkType', covariant=True, bound=Link, default=Link)
2222
SelfType = TypeVar('SelfType', bound='BaseConnectedGenerator')
2323
@non_library # this can't be instantiated
2424
class BaseConnectedGenerator(DefaultConnectionBlock, GeneratorBlock, Generic[OutputType, InputsType, LinkType]):

edg/electronics_model/PassivePort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TypeVar, Type, Dict
3+
from typing import TypeVar, Type, Dict, Mapping
44

55
from ..core import *
66
from .GroundPort import Ground

edg/electronics_model/resources/build_kicad_footprint_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def polygon_lines_area(lines: List[Line]) -> Optional[float]:
6363
return abs(sum) / 2
6464

6565

66-
def sexp_list_find_all(container: list, key: str) -> List[List[Any]]:
66+
def sexp_list_find_all(container: list[Any], key: str) -> List[List[Any]]:
6767
"""Given a sexp list, return all elements which are lists where the first element is a symbol of key."""
6868
matching_elts = []
6969
for elt in container:

edg/electronics_model/test_kicad_schematic_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import unittest
22

33
import os.path
4-
from typing import Set, Tuple, Type
4+
from typing import Set, Tuple, Type, Any
55

66
from .KiCadSchematicParser import KiCadSchematic, ParsedNet, KiCadGlobalLabel, KiCadLabel, KiCadPowerLabel
77

88

9-
def net_to_tuple(net: ParsedNet) -> Tuple[Set[Tuple[Type, str]], Set[str]]:
9+
def net_to_tuple(net: ParsedNet) -> Tuple[Set[Tuple[Type[Any], str]], Set[str]]:
1010
"""Converts a ParsedNet to a tuple of net labels and net pins, so it can be compared during unit testing."""
1111
labels = set([(x.__class__, x.name) for x in net.labels])
1212
pins = set([f"{x.refdes}.{x.pin_number}" for x in net.pins])

edg/parts/JlcPart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def __init__(self, *args: Any, require_basic_part: BoolLike = False, **kwargs: A
1818
self.require(self.require_basic_part.implies(self.actual_basic_part), "required basic part")
1919

2020

21-
DescriptionParser = Tuple[re.Pattern,
22-
Callable[[re.Match], Dict[PartsTableColumn, Any]]]
21+
DescriptionParser = Tuple[re.Pattern[str],
22+
Callable[[re.Match[str]], Dict[PartsTableColumn, Any]]]
2323
class JlcTableBase(PartsTableBase):
2424
"""Defines common table headers, columns, and functionality for parsing JLCPCB parts tables."""
2525
PART_NUMBER_COL = 'MFR.Part' # used only for translation to the PartsTableFootprint col
@@ -63,7 +63,7 @@ def _parse_jlcpcb_common(cls, row: PartsTableRow) -> Dict[PartsTableColumn, Any]
6363
}
6464

6565
@staticmethod
66-
def parse(description: str, regex_dictionary: Dict[str, re.Pattern]) -> Dict[str, str]:
66+
def parse(description: str, regex_dictionary: Dict[str, re.Pattern[str]]) -> Dict[str, str]:
6767
extraction_table = {}
6868

6969
for key, pattern in regex_dictionary.items():

examples/jlcpcb_pcba_postprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def remap_by_dict(elt: str, remap_dict: Dict[str, str]) -> str:
144144
if os.path.exists(f'{args.file_path_prefix}.csv'): # remove previous one to avoid confusion
145145
os.remove(f'{args.file_path_prefix}.csv')
146146
with open(f'{args.file_path_prefix}.csv', 'w', newline='') as bom_out:
147-
merged_csv_out: Optional[csv.DictWriter] = None
147+
merged_csv_out: Optional[csv.DictWriter[str]] = None
148148
for input_bom_file in args.merge_boms:
149149
with open(input_bom_file, 'r', newline='') as bom_in:
150150
csv_dict_in = csv.DictReader(bom_in)

0 commit comments

Comments
 (0)