Skip to content

Commit e37b958

Browse files
committed
sort some type issues
1 parent 39ff49c commit e37b958

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

chipflow_lib/platforms/utils.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from typing import (
1515
Any, Dict, List, Set,
1616
Tuple, Optional, Union, Literal,
17-
Annotated
17+
Annotated, NamedTuple
1818
)
1919
from typing_extensions import (
2020
TypedDict, Unpack, NotRequired
@@ -173,7 +173,7 @@ def __repr__(self):
173173
return f"IOSignature({','.join('{0}={1!r}'.format(k,v) for k,v in self._model.items())})"
174174

175175

176-
def OutputIOSignature(width: int, **kwargs: Unpack[IOModel]):
176+
def OutputIOSignature(width: int, **kwargs: Unpack[IOModel]): # type: ignore[reportGeneralTypeIssues]
177177
"""This creates an :py:obj:`Amaranth Signature <amaranth.lib.wiring.Signature>` which is then used to decorate package output signals
178178
intended for connection to the physical pads of the integrated circuit package.
179179
@@ -186,7 +186,7 @@ def OutputIOSignature(width: int, **kwargs: Unpack[IOModel]):
186186
return IOSignature(**kwargs)
187187

188188

189-
def InputIOSignature(width:int, **kwargs: Unpack[IOModel]):
189+
def InputIOSignature(width:int, **kwargs: Unpack[IOModel]): # type: ignore[reportGeneralTypeIssues]
190190
"""This creates an :py:obj:`Amaranth Signature <amaranth.lib.wiring.Signature>` which is then used to decorate package input signals
191191
intended for connection to the physical pads of the integrated circuit package.
192192
@@ -199,7 +199,7 @@ def InputIOSignature(width:int, **kwargs: Unpack[IOModel]):
199199
return IOSignature(**kwargs)
200200

201201

202-
def BidirIOSignature(width:int , **kwargs: Unpack[IOModel]):
202+
def BidirIOSignature(width:int , **kwargs: Unpack[IOModel]): # type: ignore[reportGeneralTypeIssues]
203203
"""This creates an :py:obj:`Amaranth Signature <amaranth.lib.wiring.Signature>` which is then used to decorate package bi-directional signals
204204
intended for connection to the physical pads of the integrated circuit package.
205205
@@ -743,8 +743,7 @@ def _jtag(self) -> JTAGPins:
743743
tdo=start_pin + 4
744744
)
745745

746-
@dataclass
747-
class GAPin:
746+
class GAPin(NamedTuple):
748747
h: str
749748
w: int
750749
def __lt__(self, other):
@@ -829,7 +828,7 @@ def int_to_alpha(i: int):
829828
out = valid_letters[char-1] + out
830829
return out
831830

832-
def pins_for_range(h1: int, h2: int, w1: int, w2: int) -> Set[Pin]:
831+
def pins_for_range(h1: int, h2: int, w1: int, w2: int) -> Set[GAPin]:
833832
pins = [GAPin(int_to_alpha(h),w) for h in range(h1, h2) for w in range(w1, w2)]
834833
return set(pins)
835834

@@ -890,7 +889,7 @@ def allocate_pins(self, process: 'Process', lockfile: LockFile|None) -> 'LockFil
890889
portmap = _linear_allocate_components(self._interfaces, lockfile, self._allocate, set(self._ordered_pins))
891890
return LockFile(package=Package(type=self), process=process, metadata=self._interfaces, port_map=portmap)
892891

893-
def _allocate(self, available: Set[str], width: int) -> List[str]:
892+
def _allocate(self, available: Set[Pin], width: int) -> List[Pin]:
894893
avail_n = sorted(available)
895894
logger.debug(f"GAPackageDef.allocate {width} from {len(avail_n)} remaining: {available}")
896895
ret = _find_contiguous_sequence(self._ordered_pins, avail_n, width)

0 commit comments

Comments
 (0)