Skip to main content

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 from qiskit and should have few false positives.

[!WARNING] This tool does not detect 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 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

flake8_qiskit_migration-0.5.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_qiskit_migration-0.5.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

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

Hashes for flake8_qiskit_migration-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a84c9f0a945dcee18389508ed72969a9de8657130d63fa22939ef60fe32991d6
MD5 0bdca48771aa6ff177de195737580936
BLAKE2b-256 188d41fa6e0d3d42ac012e42f149cdf25207a1c8134495aed139c47afd6da15b

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flake8_qiskit_migration-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_qiskit_migration-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7d95a9e069dcb8d73511c27be12ba394c9099d0a40da186ac62973540dae6d1
MD5 65599668fd4ace3bed3ff54a8f8af66a
BLAKE2b-256 fca4a7ae2aa2f4f4a9fed2a89482de93d7e9ff136dcad49c5b5db1400039f70d

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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