Skip to main content

Quickly detect imports removed in the Qiskit 1.0 release

Project description

flake8-qiskit-migration

Flake8 plugin to detect imports deprecated in Qiskit 1.0. For a full migration guide, see Qiskit 1.0 feature changes.

[!WARNING] This tool only detects deprecated import paths, it does not detect use of deprecated methods (such as QuantumCircuit.qasm), deprecated arguments, or assignments such as qk = qiskit (although it can handle aliases such as import qiskit as qk).

This tool is to help you quickly identify deprecated imports and work out how to fix them. This tool is not perfect and will make some mistakes, so make sure to test your project thoroughly after migrating.

Through pipx

We recommend using this plugin through pipx. If you have pipx installed, simply run:

pipx run flake8-qiskit-migration <path-to-source>

This will install this plugin in a temporary environment and run it. If you're at the root of your Python project, then <path-to-source> is ./.

With Python venv

If you don't want to use pipx, you can manually create a new environment for the linter. This approach also lets you use nbqa to check Jupyter notebooks. Delete the environment when you're finished.

# 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>  # e.g. `src/`

# Run plugin on notebooks
pip install nbqa
nbqa flake8 ./**/*.ipynb --select QKT100

# Deactivate and delete environment
deactivate
rm -r .flake8-qiskit-migration-venv

With existing flake8

If you already have flake8 installed and want run this plugin that way, To run only the deprecation detection plugin (QKT100), use the --select argument. You'll probably want to uninstall it when you're done.

# Install plugin
pip install flake8-qiskit-migration

# Run all flake8 checks (including this plugin)
flake8 <path-to-source>

# Run only this plugin
flake8 --select QKT100 <path-to-source>

# Uninstall plugin
pip uninstall flake8-qiskit-migration

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_qiskit_migration-0.4.0.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

flake8_qiskit_migration-0.4.0-py3-none-any.whl (11.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page