Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Create a transpiler plugin" uses Python >3.9 features #1552

Closed
frankharkins opened this issue Jun 14, 2024 · 3 comments
Closed

"Create a transpiler plugin" uses Python >3.9 features #1552

frankharkins opened this issue Jun 14, 2024 · 3 comments
Assignees

Comments

@frankharkins
Copy link
Member

The notebook docs/transpile/create-a-transpiler-plugin.ipynb is failing in https://github.com/Qiskit/documentation/actions/runs/9485973981/job/26139208772?pr=1537:

 Cell In[1], line 12, in MyLayoutPlugin()
      8 class MyLayoutPlugin(PassManagerStagePlugin):
      9     def pass_manager(
     10         self,
     11         pass_manager_config: PassManagerConfig,
---> 12         optimization_level: int | None = None,
     13     ) -> PassManager:
     14         layout_pm = PassManager(
     15             [
     16                 VF2Layout(
   (...)
     22             ]
     23         )
     24         layout_pm += common.generate_embed_passmanager(pass_manager_config.coupling_map)

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

This is because that syntax was introduced in Python 3.10, but we test the notebooks with Python 3.9 (as that's the lowest version Qiskit supports).

Options to fix this are:

  • a) Replace int|None with Optional[int] (my preferred choice)
  • b) Use from __future__ import annotations
  • c) Decide to test notebooks on Python 3.10 or newer
@Eric-Arellano
Copy link
Collaborator

We should do either option 1 or 2. It's useful for users if the notebook works with Python 3.9 because they might be using 3.9 locally. I'm fine with option 1.

@frankharkins
Copy link
Member Author

frankharkins commented Jun 19, 2024

Plot thickens: It already has the future import...

@frankharkins
Copy link
Member Author

This was fixed in #1546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants