Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move QPY version regex construction to import time #8235

Merged
merged 3 commits into from
Jun 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions qiskit/qpy/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"""
+ "$"
)
VERSION_PATTERN_REGEX = re.compile(VERSION_PATTERN)
mtreinish marked this conversation as resolved.
Show resolved Hide resolved


@deprecate_arguments({"circuits": "programs"})
Expand Down Expand Up @@ -149,7 +150,7 @@ def dump(
else:
raise TypeError(f"'{program_type}' is not supported data type.")

version_match = re.search(VERSION_PATTERN, __version__, re.VERBOSE | re.IGNORECASE)
version_match = VERSION_PATTERN_REGEX.search(__version__, re.VERBOSE | re.IGNORECASE)
version_parts = [int(x) for x in version_match.group("release").split(".")]
header = struct.pack(
formats.FILE_HEADER_PACK,
Expand Down Expand Up @@ -226,7 +227,7 @@ def load(
)
if data.preface.decode(common.ENCODE) != "QISKIT":
raise QiskitError("Input file is not a valid QPY file")
version_match = re.search(VERSION_PATTERN, __version__, re.VERBOSE | re.IGNORECASE)
version_match = VERSION_PATTERN_REGEX.search(__version__, re.VERBOSE | re.IGNORECASE)
version_parts = [int(x) for x in version_match.group("release").split(".")]

header_version_parts = [data.major_version, data.minor_version, data.patch_version]
Expand Down