Add flake8 tool instructions to migration guide (#875)

Adds instructions on using the flake8 plugin to detect deprecated
imports.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
This commit is contained in:
Frank Harkins 2024-02-27 18:17:12 +00:00 committed by GitHub
parent 5c9c97b520
commit 929d1c55e9
2 changed files with 53 additions and 0 deletions

View File

@ -48,6 +48,7 @@ multiqubit
openqasm
parameterizing
Paulihedral
pipx
polynomially
pygments
pyplot

View File

@ -8,6 +8,58 @@ description: Description of feature changes introduced in Qiskit 1.0 and how to
This guide describes migration paths for the most important feature changes in Qiskit&reg; 1.0, organized by module.
Use the table of contents on the right side to navigate to the module you are interested in.
## Qiskit 1.0 migration tool
To ease the migration process, you can use the
[`flake8-qiskit-migration`](https://github.com/qiskit-community/flake8-qiskit-migration)
tool to detect removed import paths in your code and suggest alternatives.
<Tabs>
<TabItem value="flake8-pipx" label="Run with pipx" default>
If you have [`pipx`](https://github.com/pypa/pipx) installed, simply run
the following command.
```sh
pipx run flake8-qiskit-migration <path-to-source-directory>
```
This will install the package to a temporary virtual environment and run
it on your code.
</TabItem>
<TabItem value="flake8-venv" label="Run with venv" default>
If you don't want to use `pipx`, you can manually create a new
environment for the tool. This approach also lets you use
[`nbqa`](https://github.com/nbQA-dev/nbQA) to check code examples in
Jupyter notebooks. Delete the environment when you're finished.
```sh
# Make new environment and install
python -m venv .flake8-qiskit-migration-venv
source .flake8-qiskit-migration-venv/bin/activate
pip install flake8-qiskit-migration
# Run plugin on Python code
flake8 --select QKT100 <path-to-source-directory> # e.g. `src/`
# (Optional) run plugin on notebooks
pip install nbqa
nbqa flake8 ./**/*.ipynb --select QKT100
# Deactivate and delete environment
deactivate
rm -r .flake8-qiskit-migration-venv
```
</TabItem>
</Tabs>
<Admonition type="note" title="Limitations">
This tool only detects removed import paths. It does not detect the use of removed
methods (such as `QuantumCircuit.qasm`) or arguments. It also can't keep track
of assignments such as `qk = qiskit`, although it can handle aliases such as
`import qiskit as qk`.
</Admonition>
For more information, see the [project's
repository](https://github.com/qiskit-community/flake8-qiskit-migration).
<span id="qiskit.global"></span>
## Global instances and functions