quantumlib/Stim

Small typing issue in the Python method `CircuitRepeatBlock.name`

Closed this issue · 0 comments

The method below

@property
def name(
self,
) -> object:
"""Returns the name "REPEAT".
This is a duck-typing convenience method. It exists so that code that doesn't
know whether it has a `stim.CircuitInstruction` or a `stim.CircuitRepeatBlock`
can check the object's name without having to do an `instanceof` check first.
Examples:
>>> import stim
>>> circuit = stim.Circuit('''
... H 0
... REPEAT 5 {
... CX 1 2
... }
... S 1
... ''')
>>> [instruction.name for instruction in circuit]
['H', 'REPEAT', 'S']
"""

is guaranteed to return "REPEAT" per the docstring. Nevertheless, its annotated return type is object, that is not invalid per-se but is not as precise as it should be (i.e., str).