Skip to content

Commit d5a591c

Browse files
Copilotaborgna-q
andauthored
revert: Restore deprecated tket-py definitions removed in #1975 (#1978)
#1975 removed two deprecated public symbols from `tket-py`, breaking downstream users before a deprecation cycle had run its course. This restores them while keeping that PR's non-breaking drive-by fixes. ### Restored - `tket.passes.NormalizeGuppy` — deprecated alias of `Normalize`, plus its `__all__` entry and `test_normalize_guppy_deprecated_alias`. - `tket.metadata.PytketPhaseExpr` — deprecated metadata key (`TKET1.phase`), plus its `__all__` entry. ```python from tket.passes import NormalizeGuppy # DeprecationWarning: Use `Normalize` instead. from tket.metadata import PytketPhaseExpr ``` ### Kept from #1975 - Doc-example fixes and the added `ExpectedQubitsHint` entry in `tket.metadata.__all__`. ### Notes - The `_QSystemLLVMPass` → `QSystemLLVMPass` rename listed in #1975's description was never actually applied in code, so there is nothing to revert there. - Unrelated pre-existing nit, left alone: the `tket/metadata.py` module docstring example imports `MaxQubitsHint` but uses `ExpectedQubitsHint`. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aborgna-q <121866228+aborgna-q@users.noreply.github.com>
1 parent c96e334 commit d5a591c

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎tket-py/test/test_pass.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
InlineFunctions,
2323
ModifierResolverPass,
2424
Normalize,
25+
NormalizeGuppy,
2526
PlatformTarget,
2627
PytketHugrPass,
2728
QSystemRebasePass,
@@ -292,6 +293,13 @@ def test_normalize_guppy():
292293
assert normal_circ1.circuit_cost(lambda op: int(op == TketOp.CX)) == 3
293294

294295

296+
def test_normalize_guppy_deprecated_alias():
297+
with pytest.deprecated_call(match="Use `Normalize` instead"):
298+
normalize = NormalizeGuppy()
299+
300+
assert isinstance(normalize, Normalize)
301+
302+
295303
def test_modifier_resolver() -> None:
296304
normalize = Normalize(resolve_modifiers=False)
297305
normalize_with_modifier_resolution = Normalize()

‎tket-py/tket/metadata.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from hugr.metadata import Metadata
2929
from pydantic import StrictBool, TypeAdapter
3030
from pydantic.dataclasses import dataclass
31+
from typing_extensions import deprecated
3132

3233
from ._tket import metadata as _metadata
3334

@@ -50,6 +51,7 @@
5051
"PytketBitRegisterNames",
5152
"PytketInputParameters",
5253
"PytketOpGroup",
54+
"PytketPhaseExpr",
5355
"PytketQubit",
5456
"PytketQubitRegisterNames",
5557
"RewriteTraceValue",
@@ -197,6 +199,17 @@ def from_json(cls, value: JsonType) -> list[PytketQubit]:
197199
return _read_pytket_register(cls.KEY, value)
198200

199201

202+
@deprecated("Call `used_extensions` on the hugr instead.")
203+
class PytketPhaseExpr(Metadata[str]):
204+
"""Metadata key for the serialized pytket global phase expression.
205+
206+
Deprecated:
207+
Use explicit ``tket.global_phase`` operations instead.
208+
"""
209+
210+
KEY = "TKET1.phase"
211+
212+
200213
def _store_pytket_register(value: list[tuple[str, list[int]]]) -> JsonType:
201214
return [[name, list(indices)] for name, indices in value]
202215

‎tket-py/tket/passes/__init__.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
implement_pass_run,
1616
)
1717
from hugr.passes.scope import GlobalScope, PassScope
18+
from typing_extensions import deprecated
1819

1920
from tket import _state
2021

@@ -33,6 +34,7 @@
3334
"InlineFunctions",
3435
"ModifierResolverPass",
3536
"Normalize",
37+
"NormalizeGuppy",
3638
"PassResult",
3739
"PlatformTarget",
3840
"PytketHugrPass",
@@ -226,6 +228,11 @@ def _run_tk(self, program: _state.CompilationState) -> _state.CompilationState:
226228
return program
227229

228230

231+
@deprecated("Use `Normalize` instead.")
232+
class NormalizeGuppy(Normalize):
233+
"""Deprecated alias for :py:class:`Normalize`."""
234+
235+
229236
@cache
230237
def _cliffordize_matcher() -> RuleMatcher:
231238
"""Build the matcher containing the supported Cliffordize rules."""

0 commit comments

Comments
 (0)