Skip to content

Commit

Permalink
Make Hugr covariant
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Aug 22, 2024
1 parent 9d3501f commit 677ec36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions hugr-py/src/hugr/build/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

from __future__ import annotations

from typing import (
Protocol,
cast,
)
from typing import TYPE_CHECKING, Protocol, TypeVar, cast

from hugr.hugr.base import Hugr, OpVar
from hugr.hugr.node_port import (
Node,
ToNode,
)
from hugr.ops import Op

if TYPE_CHECKING:
from hugr.hugr.base import Hugr

OpVar = TypeVar("OpVar", bound=Op)


class ParentBuilder(ToNode, Protocol[OpVar]):
Expand Down
2 changes: 1 addition & 1 deletion hugr-py/src/hugr/hugr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def to_serial(self, node: Node) -> SerialOp:

P = TypeVar("P", InPort, OutPort)
K = TypeVar("K", InPort, OutPort)
OpVar = TypeVar("OpVar", bound=Op)
OpVar = TypeVar("OpVar", bound=Op, covariant=True)
OpVar2 = TypeVar("OpVar2", bound=Op)


Expand Down

0 comments on commit 677ec36

Please sign in to comment.