-
Notifications
You must be signed in to change notification settings - Fork 3k
Define __all__ for qiskit #7274
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
Changes from 9 commits
af23cd3
faef0f4
7301ee0
09178e9
ff97746
8a5097a
48780c7
9145a13
6f37587
e14df4b
76370cc
1436cd3
fa77b95
7975aaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |||
| import pkgutil | ||||
| import sys | ||||
| import warnings | ||||
| import os | ||||
|
|
||||
| # qiskit errors operator | ||||
| from qiskit.exceptions import QiskitError, MissingOptionalLibraryError | ||||
|
|
@@ -127,3 +126,23 @@ def __getattr__(self, attr): | |||
|
|
||||
| Aer = AerWrapper() | ||||
| IBMQ = IBMQWrapper() | ||||
|
|
||||
| __all__ = [ | ||||
| "Aer", | ||||
| "AncillaRegister", | ||||
| "BasicAer", | ||||
| "ClassicalRegister", | ||||
| "_config", | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We probably don't want to be exporting a private name by default, unless there's a really good reason to.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's still usable, but at the very least I'd think something like that ought to be through qualified access, so we're fine not to include it in |
||||
| "IBMQ", | ||||
| "MissingOptionalLibraryError", | ||||
| "QiskitError", | ||||
| "__qiskit_version__", | ||||
| "__version__", | ||||
|
1ucian0 marked this conversation as resolved.
Outdated
|
||||
| "QuantumCircuit", | ||||
| "QuantumRegister", | ||||
| "assemble", | ||||
| "execute", | ||||
| "schedule", | ||||
| "sequence", | ||||
| "transpile", | ||||
| ] | ||||
|
1ucian0 marked this conversation as resolved.
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| upgrade: | ||
| - | | ||
| In this version, ``from qiskit import *`` wont import submodules, but only a selected list of objects. | ||
| This might break existing code using ``from qiskit import *`` and refering to objctes 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. | ||
|
1ucian0 marked this conversation as resolved.
Outdated
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 osgot 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.