Skip to content
Merged
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
27 changes: 27 additions & 0 deletions qiskit/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@
is not present, but will raise :exc:`OptionalDependencyImportWarning` to let you know about it.

.. autoexception:: OptionalDependencyImportWarning

When experimental features are being used, Qiskit will raise :exc:`ExperimentalWarning`.
Comment thread
jakelishman marked this conversation as resolved.

.. warning::

Qiskit experimental features can break at any minor release and their API might change without
previous notification. Their use is not recommended in production.

.. autoexception:: ExperimentalWarning

Filtering warnings
------------------

Python has built-in mechanisms to filter warnings, described in the documentation of the
:mod:`warnings` module. You can use these subclasses in your warning filters from within Python to
silence warnings you are not interested in. For example, if you are knowingly using experimental
features and are comfortable that they make break in later versions, you can silence
:exc:`ExperimentalWarning` like this::

import warnings
from qiskit.exceptions import ExperimentalWarning

warnings.filterwarnings("ignore", category=ExperimentalWarning)
"""

from typing import Optional
Expand Down Expand Up @@ -124,3 +147,7 @@ class OptionalDependencyImportWarning(QiskitWarning):
"""Raised when an optional library raises errors during its import."""

# Not a subclass of `ImportWarning` because those are hidden by default.


class ExperimentalWarning(QiskitWarning):
"""Raised when an experimental feature is being used."""