From 80e68324c71e8d65725e8ae788773decd47002de Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Tue, 18 Jun 2024 15:37:56 +0100 Subject: [PATCH] fix: incorrect typevar use in _get_typed_op --- hugr-py/src/hugr/_cfg.py | 4 +--- hugr-py/src/hugr/_hugr.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hugr-py/src/hugr/_cfg.py b/hugr-py/src/hugr/_cfg.py index 97847967a..429c93de0 100644 --- a/hugr-py/src/hugr/_cfg.py +++ b/hugr-py/src/hugr/_cfg.py @@ -116,9 +116,7 @@ def branch_exit(self, src: Wire) -> None: src = src.out_port() self.hugr.add_link(src, self.exit.inp(0)) - src_block: ops.DataflowBlock = self.hugr._get_typed_op( - src.node, ops.DataflowBlock - ) + src_block = self.hugr._get_typed_op(src.node, ops.DataflowBlock) out_types = src_block.nth_outputs(src.offset) if self._exit_op._cfg_outputs is not None: if self._exit_op._cfg_outputs != out_types: diff --git a/hugr-py/src/hugr/_hugr.py b/hugr-py/src/hugr/_hugr.py index 1dfede794..a54d35e6a 100644 --- a/hugr-py/src/hugr/_hugr.py +++ b/hugr-py/src/hugr/_hugr.py @@ -133,6 +133,7 @@ def to_serial(self, node: Node, hugr: Hugr) -> SerialOp: P = TypeVar("P", InPort, OutPort) K = TypeVar("K", InPort, OutPort) OpVar = TypeVar("OpVar", bound=Op) +OpVar2 = TypeVar("OpVar2", bound=Op) @dataclass(frozen=True, eq=True, order=True) @@ -189,7 +190,7 @@ def __iter__(self): def __len__(self) -> int: return self.num_nodes() - def _get_typed_op(self, node: ToNode, cl: PyType[OpVar]) -> OpVar: + def _get_typed_op(self, node: ToNode, cl: PyType[OpVar2]) -> OpVar2: op = self[node].op assert isinstance(op, cl) return op