Since this project is restricted to Python 3.10 and above, we can take advantage of the newer, preferred syntax for combined types using the pipe (|) operator in type annotations. This syntax is more concise and replaces the need for Union from the typing module.
For example:
from typing import Union
def validate(program: Union[openqasm3.ast.Program, str]) -> None:
can now be simplified to:
def validate(program: openqasm3.ast.Program | str) -> None:
We should apply this updated syntax to all instances where Union is used.
Since this project is restricted to Python 3.10 and above, we can take advantage of the newer, preferred syntax for combined types using the pipe (
|) operator in type annotations. This syntax is more concise and replaces the need forUnionfrom thetypingmodule.For example:
can now be simplified to:
We should apply this updated syntax to all instances where
Unionis used.