qiskit_code_static_check
Analyze Qiskit code for compatibility and errors by executing it in a virtual environment with specified Qiskit versions. Identify unsupported modules or functions and get recommendations for migration. Supports custom dependencies for thorough static analysis.
Instructions
Check the provided Qiskit code for static analysis.
This function runs the code in a temporary virtual environment with the specified Qiskit version.
AI models are likely trained on Qiskit v0 and may not be familiar with v1 or v2.
Therefore, we perform static analysis by running AI-generated code on v1 or v2.
Errors will occur if the code uses modules or functions that are no longer supported.
In such cases, please refer to the v1 or v2 migration guide or similar tutorials.
Use v2 unless you have a specific reason not to.
If you need other dependencies like qiskit-ibm-runtime or qiskit-aer, please specify them as a list in other_dependencies.
Args:
code (str): AI-generated Qiskit code to check.
qiskit_version (typ.Literal["v1", "v2"]): The Qiskit version to use for checking the code.
other_dependencies (typ.Optional[list[str]], optional): List of other dependencies to include. Defaults to None.
Returns:
dict: The result of the static analysis, including any errors or warnings.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
code | Yes | ||
other_dependencies | No | ||
qiskit_version | Yes |
Input Schema (JSON Schema)
{
"properties": {
"code": {
"title": "Code",
"type": "string"
},
"other_dependencies": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Other Dependencies"
},
"qiskit_version": {
"enum": [
"v1",
"v2"
],
"title": "Qiskit Version",
"type": "string"
}
},
"required": [
"code",
"qiskit_version"
],
"title": "qiskit_code_static_checkArguments",
"type": "object"
}