From 929d1c55e92d96ce05fd8dd4921b52000e8e791d Mon Sep 17 00:00:00 2001 From: Frank Harkins Date: Tue, 27 Feb 2024 18:17:12 +0000 Subject: [PATCH] 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> --- cspell/dictionaries/qiskit.txt | 1 + .../migration-guides/qiskit-1.0-features.mdx | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/cspell/dictionaries/qiskit.txt b/cspell/dictionaries/qiskit.txt index bd3bee7a49..9cbbf7544f 100644 --- a/cspell/dictionaries/qiskit.txt +++ b/cspell/dictionaries/qiskit.txt @@ -48,6 +48,7 @@ multiqubit openqasm parameterizing Paulihedral +pipx polynomially pygments pyplot diff --git a/docs/api/migration-guides/qiskit-1.0-features.mdx b/docs/api/migration-guides/qiskit-1.0-features.mdx index fd16365c41..74a8c25b95 100644 --- a/docs/api/migration-guides/qiskit-1.0-features.mdx +++ b/docs/api/migration-guides/qiskit-1.0-features.mdx @@ -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® 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. + + + + If you have [`pipx`](https://github.com/pypa/pipx) installed, simply run + the following command. + ```sh + pipx run flake8-qiskit-migration + ``` + This will install the package to a temporary virtual environment and run + it on your code. + + + 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 # 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 + ``` + + + + +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`. + + +For more information, see the [project's +repository](https://github.com/qiskit-community/flake8-qiskit-migration). + + ## Global instances and functions