Detect deprecated/removed imports, methods, and arguments in Qiskit 1.0 and 2.0
Project description
flake8-qiskit-migration
Flake8 plugin to detect deprecated/removed imports, methods, and arguments in Qiskit 1.0 and 2.0.
Error codes
| Code | What it detects |
|---|---|
| QKT100 | Import paths deprecated in Qiskit 1.0 (migration guide) |
| QKT101 | Method calls removed in Qiskit 1.0 (e.g. .qasm(), .cnot(), .bind_parameters()) |
| QKT102 | Keyword arguments removed in Qiskit 1.0 (e.g. PassManager.append(max_iteration=...)) |
| QKT200 | Import paths removed in Qiskit 2.0 (migration guide) |
| QKT201 | Method calls removed in Qiskit 2.0 (e.g. .c_if(), .add_calibration(), .drive_channel()) |
| QKT202 | Keyword arguments removed in Qiskit 2.0 (e.g. transpile(backend_properties=...)) |
[!NOTE] QKT101/QKT102/QKT201 use heuristic detection (method name matching in files that import
qiskit). Without type inference, false positives are possible but unlikely for the Qiskit-specific names we check. QKT202 tracks which functions were imported fromqiskitand should have few false positives.
[!WARNING] This tool does not detect assignments such as
qk = qiskit(although it can handle aliases such asimport qiskit as qk).
This tool is to help you quickly identify deprecated API usage and work out how to fix it. 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 all migration checks
flake8 --select QKT <path-to-source> # e.g. `src/`
# Run only Qiskit 1.0 checks (imports + methods)
flake8 --select QKT1 <path-to-source>
# Run only Qiskit 2.0 checks (imports + methods + kwargs)
flake8 --select QKT2 <path-to-source>
# Run only import checks
flake8 --select QKT100,QKT200 <path-to-source>
# Run plugin on notebooks
pip install nbqa
nbqa flake8 ./**/*.ipynb --select QKT
# 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, 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 (all checks)
flake8 --select QKT <path-to-source>
# Run only Qiskit 1.0 checks
flake8 --select QKT1 <path-to-source>
# Run only Qiskit 2.0 checks
flake8 --select QKT2 <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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8_qiskit_migration-0.5.0.tar.gz.
File metadata
- Download URL: flake8_qiskit_migration-0.5.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a84c9f0a945dcee18389508ed72969a9de8657130d63fa22939ef60fe32991d6
|
|
| MD5 |
0bdca48771aa6ff177de195737580936
|
|
| BLAKE2b-256 |
188d41fa6e0d3d42ac012e42f149cdf25207a1c8134495aed139c47afd6da15b
|
Provenance
The following attestation bundles were made for flake8_qiskit_migration-0.5.0.tar.gz:
Publisher:
python-publish.yml on qiskit-community/flake8-qiskit-migration
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flake8_qiskit_migration-0.5.0.tar.gz -
Subject digest:
a84c9f0a945dcee18389508ed72969a9de8657130d63fa22939ef60fe32991d6 - Sigstore transparency entry: 985040789
- Sigstore integration time:
-
Permalink:
qiskit-community/flake8-qiskit-migration@62ed3976b497c7e647b4d03e6737705a4408cbb7 -
Branch / Tag:
refs/tags/0.5.2 - Owner: https://github.com/qiskit-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@62ed3976b497c7e647b4d03e6737705a4408cbb7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file flake8_qiskit_migration-0.5.0-py3-none-any.whl.
File metadata
- Download URL: flake8_qiskit_migration-0.5.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7d95a9e069dcb8d73511c27be12ba394c9099d0a40da186ac62973540dae6d1
|
|
| MD5 |
65599668fd4ace3bed3ff54a8f8af66a
|
|
| BLAKE2b-256 |
fca4a7ae2aa2f4f4a9fed2a89482de93d7e9ff136dcad49c5b5db1400039f70d
|
Provenance
The following attestation bundles were made for flake8_qiskit_migration-0.5.0-py3-none-any.whl:
Publisher:
python-publish.yml on qiskit-community/flake8-qiskit-migration
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flake8_qiskit_migration-0.5.0-py3-none-any.whl -
Subject digest:
f7d95a9e069dcb8d73511c27be12ba394c9099d0a40da186ac62973540dae6d1 - Sigstore transparency entry: 985040793
- Sigstore integration time:
-
Permalink:
qiskit-community/flake8-qiskit-migration@62ed3976b497c7e647b4d03e6737705a4408cbb7 -
Branch / Tag:
refs/tags/0.5.2 - Owner: https://github.com/qiskit-community
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@62ed3976b497c7e647b4d03e6737705a4408cbb7 -
Trigger Event:
release
-
Statement type: