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

Remove __qiskit_version__ (deprecated in Qiskit Terra 0.25) #11305

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@
from qiskit.compiler import transpile, assemble, schedule, sequence

from .version import __version__
from .version import QiskitVersion


__qiskit_version__ = QiskitVersion()


class AerWrapper:
Expand Down
97 changes: 0 additions & 97 deletions qiskit/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

import os
import subprocess
from collections.abc import Mapping

import warnings

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

Expand Down Expand Up @@ -85,97 +82,3 @@ def get_version_info():


__version__ = get_version_info()


class QiskitVersion(Mapping):
"""DEPRECATED in 0.25.0 use qiskit.__version__"""

__slots__ = ["_version_dict", "_loaded"]

def __init__(self):
self._version_dict = {
"qiskit": __version__,
}
self._loaded = False

def _load_versions(self):
warnings.warn(
"qiskit.__qiskit_version__ is deprecated since "
"Qiskit Terra 0.25.0, and will be removed 3 months or more later. "
"Instead, you should use qiskit.__version__. The other packages listed in the"
"former qiskit.__qiskit_version__ have their own __version__ module level dunder, "
"as standard in PEP 8.",
category=DeprecationWarning,
stacklevel=3,
)
try:
# TODO: Update to use qiskit_aer instead when we remove the
# namespace redirect
from qiskit.providers import aer

self._version_dict["qiskit-aer"] = aer.__version__
except Exception:
self._version_dict["qiskit-aer"] = None
try:
from qiskit import ignis

self._version_dict["qiskit-ignis"] = ignis.__version__
except Exception:
self._version_dict["qiskit-ignis"] = None
try:
from qiskit.providers import ibmq

self._version_dict["qiskit-ibmq-provider"] = ibmq.__version__
except Exception:
self._version_dict["qiskit-ibmq-provider"] = None
try:
import qiskit_nature

self._version_dict["qiskit-nature"] = qiskit_nature.__version__
except Exception:
self._version_dict["qiskit-nature"] = None
try:
import qiskit_finance

self._version_dict["qiskit-finance"] = qiskit_finance.__version__
except Exception:
self._version_dict["qiskit-finance"] = None
try:
import qiskit_optimization

self._version_dict["qiskit-optimization"] = qiskit_optimization.__version__
except Exception:
self._version_dict["qiskit-optimization"] = None
try:
import qiskit_machine_learning

self._version_dict["qiskit-machine-learning"] = qiskit_machine_learning.__version__
except Exception:
self._version_dict["qiskit-machine-learning"] = None
self._loaded = True

def __repr__(self):
if not self._loaded:
self._load_versions()
return repr(self._version_dict)

def __str__(self):
if not self._loaded:
self._load_versions()
return str(self._version_dict)

def __getitem__(self, key):
if not self._loaded:
self._load_versions()
return self._version_dict[key]

def __iter__(self):
if not self._loaded:
self._load_versions()
return iter(self._version_dict)

def __len__(self):
return len(self._version_dict)


__qiskit_version__ = QiskitVersion()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
upgrade:
- |
The variable ``qiskit.__qiskit_version__`` is removed as it was deprecated since
Qiskit 0.44 (released on July 2023).
Instead, you should use ``qiskit.__version__``. The other packages listed in the
former ``qiskit.__qiskit_version__`` have their own ``__version__`` module level dunder,
as standard in PEP 8.
26 changes: 0 additions & 26 deletions test/python/test_version.py

This file was deleted.