Skip to content

Commit

Permalink
refactor!: Make _DfBase and _DefinitionBuilder public
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Aug 22, 2024
1 parent 69186b5 commit 9d3501f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions hugr-py/src/hugr/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .base import ParentBuilder
from .cfg import Block, Cfg
from .cond_loop import Case, Conditional, If, TailLoop
from .dfg import Dfg, Function, _DefinitionBuilder, _DfBase
from .dfg import DefinitionBuilder, DfBase, Dfg, Function
from .function import Module
from .tracked_dfg import TrackedDfg

Expand All @@ -19,6 +19,6 @@
"Module",
"TrackedDfg",
"Dfg",
"_DefinitionBuilder",
"_DfBase",
"DefinitionBuilder",
"DfBase",
]
4 changes: 2 additions & 2 deletions hugr-py/src/hugr/build/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from hugr import ops, tys, val
from hugr.build.base import ParentBuilder
from hugr.build.dfg import _DfBase
from hugr.build.dfg import DfBase
from hugr.exceptions import MismatchedExit, NoSiblingAncestor, NotInSameCfg
from hugr.hugr import Hugr

Expand All @@ -19,7 +19,7 @@
from hugr.tys import Type, TypeRow


class Block(_DfBase[ops.DataflowBlock]):
class Block(DfBase[ops.DataflowBlock]):
"""Builder class for a basic block in a HUGR control flow graph."""

def set_outputs(self, *outputs: Wire) -> None:
Expand Down
6 changes: 3 additions & 3 deletions hugr-py/src/hugr/build/cond_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from hugr import ops
from hugr.build.base import ParentBuilder
from hugr.build.dfg import _DfBase
from hugr.build.dfg import DfBase
from hugr.hugr.base import Hugr
from hugr.tys import Sum

Expand All @@ -21,7 +21,7 @@
from hugr.tys import TypeRow


class Case(_DfBase[ops.Case]):
class Case(DfBase[ops.Case]):
"""Dataflow graph builder for a case in a conditional."""

_parent_cond: Conditional | None = None
Expand Down Expand Up @@ -202,7 +202,7 @@ def add_case(self, case_id: int) -> Case:


@dataclass
class TailLoop(_DfBase[ops.TailLoop]):
class TailLoop(DfBase[ops.TailLoop]):
"""Builder for a tail-controlled loop.
Args:
Expand Down
8 changes: 4 additions & 4 deletions hugr-py/src/hugr/build/dfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


@dataclass()
class _DefinitionBuilder(Generic[OpVar]):
class DefinitionBuilder(Generic[OpVar]):
"""Base class for builders that can define functions, constants, and aliases.
As this class may be a root node, it does not extend `ParentBuilder`.
Expand Down Expand Up @@ -96,7 +96,7 @@ def add_alias_defn(self, name: str, ty: Type, parent: ToNode | None = None) -> N


@dataclass()
class _DfBase(ParentBuilder[DP], _DefinitionBuilder, AbstractContextManager):
class DfBase(ParentBuilder[DP], DefinitionBuilder, AbstractContextManager):
"""Base class for dataflow graph builders.
Args:
Expand Down Expand Up @@ -637,7 +637,7 @@ def _wire_up_port(self, node: Node, offset: PortOffset, p: Wire) -> tys.Type:
return self._get_dataflow_type(src)


class Dfg(_DfBase[ops.DFG]):
class Dfg(DfBase[ops.DFG]):
"""Builder for a simple nested Dataflow graph, with root node of type
:class:`DFG <hugr.ops.DFG>`.
Expand Down Expand Up @@ -673,7 +673,7 @@ def _ancestral_sibling(h: Hugr, src: Node, tgt: Node) -> Node | None:


@dataclass
class Function(_DfBase[ops.FuncDefn]):
class Function(DfBase[ops.FuncDefn]):
"""Build a function definition as a HUGR dataflow graph.
Args:
Expand Down
4 changes: 2 additions & 2 deletions hugr-py/src/hugr/build/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import TYPE_CHECKING

from hugr import ops
from hugr.build.dfg import Function, _DefinitionBuilder
from hugr.build.dfg import DefinitionBuilder, Function
from hugr.hugr import Hugr

if TYPE_CHECKING:
Expand All @@ -17,7 +17,7 @@


@dataclass
class Module(_DefinitionBuilder[ops.Module]):
class Module(DefinitionBuilder[ops.Module]):
"""Build a top-level HUGR module.
Examples:
Expand Down

0 comments on commit 9d3501f

Please sign in to comment.