You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with the instruction being appended to a quantum circuit being of type Operation | CircuitInstruction.
In practice, however, we can add also anything that has a to_instruction method (see also this comment). It would be nice to reflect this functionality in the type hints and/or in the following docstring.
The text was updated successfully, but these errors were encountered:
Hello @alexanderivrii , I am thinking of modifying things the following way:
type hints from instruction: Operation | CircuitInstruction to instruction: InstructionLike
and docstring to include additionally in the , :class: ~.circuit would be converted into .circuit.Instruction. and include in the Args::class with .to_instruction() attribute.
What do you suggest about this? If you have a better way of putting things, kindly let me know.
I appreciate the approach of introducing InstructionLike for better type hinting in QuantumCircuit.append. It makes sense to support objects with a to_instruction() method explicitly.
A few thoughts:
Would it be beneficial to include Union[Operation, CircuitInstruction, HasToInstruction] instead of a new alias (InstructionLike)? This would keep things explicit while maintaining flexibility.
Updating the docstring to clarify that any object with a .to_instruction() method is accepted is a great idea. Maybe we can also add a small example in the documentation?
Let me know if I can assist in testing or reviewing the changes!
The
QuantumCircuit.append
method looks as followswith the instruction being appended to a quantum circuit being of type
Operation | CircuitInstruction
.In practice, however, we can add also anything that has a
to_instruction
method (see also this comment). It would be nice to reflect this functionality in the type hints and/or in the following docstring.The text was updated successfully, but these errors were encountered: