Skip to content

Commit

Permalink
fix: add wrappers to type cast int(5) to int(6)
Browse files Browse the repository at this point in the history
  • Loading branch information
qartik committed Feb 27, 2025
1 parent 52a20f9 commit 96cd5af
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions guppylang/std/qsystem/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ def discard(self: "RNG" @ owned) -> None: ...
module=qsystem_random,
)
@no_type_check
def random_int(self: "RNG") -> int: ...
def _random_int(self: "RNG") -> int: ...

@guppy(qsystem_random)
def random_int(self: "RNG") -> int:
return int(self.random_int()) # type: ignore[operator] # "RawFunctionDef" not callable

@guppy(qsystem_random)
def random_nat(self: "RNG") -> nat:
return nat(self.random_int())
return nat(self.random_int()) # type: ignore[call-arg, operator] # Too many arguments for "nat"; "RawFunctionDef" not callable

@guppy.hugr_op(
external_op("RandomFloat", [], ext=QSYSTEM_RANDOM_EXTENSION),
Expand All @@ -58,4 +62,8 @@ def random_float(self: "RNG") -> float: ...
module=qsystem_random,
)
@no_type_check
def random_int_bounded(self: "RNG", bound: int) -> int: ...
def _random_int_bounded(self: "RNG", bound: int) -> int: ...

@guppy(qsystem_random)
def random_int_bounded(self: "RNG", bound: int) -> int:
return int(self._random_int_bounded(bound))

0 comments on commit 96cd5af

Please sign in to comment.