Skip to content

Commit

Permalink
feat: Add ParamSpec to qscript.py
Browse files Browse the repository at this point in the history
  • Loading branch information
andrijapau committed Dec 16, 2024
1 parent 4555833 commit 8b40ce0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pennylane/tape/qscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from collections import Counter
from collections.abc import Callable, Hashable, Iterable, Iterator, Sequence
from functools import cached_property
from typing import Any, Optional, TypeVar, Union
from typing import Any, Optional, ParamSpec, TypeVar, Union

import pennylane as qml
from pennylane.measurements import MeasurementProcess, ProbabilityMP, StateMP
Expand Down Expand Up @@ -1376,10 +1376,12 @@ def map_to_standard_wires(self) -> "QuantumScript":
return fn(tapes)


# TODO: Use "ParamSpecs" when min Python version is 3.10
def make_qscript(
fn: Callable[..., Any], shots: Optional[ShotsLike] = None
) -> Callable[..., QuantumScript]:
# ParamSpec is used to preserve the exact signature of the input function `fn`
P = ParamSpec("P")
T = TypeVar("T")


def make_qscript(fn: Callable[P, T], shots: Optional[ShotsLike] = None) -> Callable[P, QS]:
"""Returns a function that generates a qscript from a quantum function without any
operation queuing taking place.
Expand Down

0 comments on commit 8b40ce0

Please sign in to comment.