Skip to content
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
18 changes: 17 additions & 1 deletion qiskit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import pkgutil
import sys
import warnings
import os
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this imported by mistake?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to check some environment variables here about suppressing packaging warnings - looks like import os got left after those were removed in #5619. Pylint won't moan about unused imports in __init__ by default I think, because most names in an initialiser won't be used.


# qiskit errors operator
from qiskit.exceptions import QiskitError, MissingOptionalLibraryError
Expand Down Expand Up @@ -127,3 +126,20 @@ def __getattr__(self, attr):

Aer = AerWrapper()
IBMQ = IBMQWrapper()

__all__ = [
"Aer",
"AncillaRegister",
"BasicAer",
"ClassicalRegister",
"IBMQ",
"MissingOptionalLibraryError",
"QiskitError",
"QuantumCircuit",
"QuantumRegister",
"assemble",
"execute",
"schedule",
"sequence",
"transpile",
]
8 changes: 8 additions & 0 deletions releasenotes/notes/7274-6f57628a7995a461.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
upgrade:
- |
In this version, ``from qiskit import *`` will not import submodules, but only a selected list of objects.
This might break existing code using ``from qiskit import *`` and referring to objects that are not part of the current namespace.
As a reminder, ``import *`` is considered bad practice and it should not be used in production code.
Qiskit sets ``__all__`` in ``qiskit/__init__.py`` as a way to mitigate the effects of said bad practice.
If your code raises ``name '<something>' is not defined``, add ``from qiskit import <something>`` and try again.