QCHackers / tqec

Design automation software tools for Topological Quantum Error Correction
https://tqec.app
Apache License 2.0
58 stars 15 forks source link

Small typing issue in backend #223

Closed nelimee closed 1 month ago

nelimee commented 1 month ago

Describe the bug

The last line of

https://github.com/QCHackers/tqec/blob/d2a9d2fce649fe1b614dbcb90e0494716109f4b1/src/tqec/circuit/operations/measurement_map.py#L151-L155

is raising the typing issue

Index 0 is out of range for type Tuple[()]Pylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)

Expected behavior

No typing issue.

Additional context

Currently, we check if the number of qubits is strictly superior to 1. If that is the case, an exception is raised. That means that the number of qubits can be either 0 or 1. The typing analyser is showing this error because, if it turns out that there are no qubits (i.e. 0), trying to get the first one will raise an error.