diff --git a/pyproject.toml b/pyproject.toml index 97ccde21d1b7..b4e4a566f57c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -240,3 +240,12 @@ enable = [ [tool.pylint.spelling] spelling-private-dict-file = ".local-spellings" + +[tool.coverage.report] +exclude_also = [ + "def __repr__", # Printable epresentational string does not typically execute during testing + "raise NotImplementedError", # Abstract methods are not testable + "raise RuntimeError", # Exceptions for defensive programming that cannot be tested a head + "if TYPE_CHECKING:", # Code that only runs during type checks + "@abstractmethod", # Abstract methods are not testable + ] diff --git a/qiskit/qasm3/exporter.py b/qiskit/qasm3/exporter.py index 16bc2529ca74..14d83213604a 100644 --- a/qiskit/qasm3/exporter.py +++ b/qiskit/qasm3/exporter.py @@ -837,7 +837,7 @@ def build_current_scope(self) -> List[ast.Statement]: statements.append(self.build_if_statement(instruction)) elif isinstance(instruction.operation, SwitchCaseOp): statements.extend(self.build_switch_statement(instruction)) - else: # pragma: no cover + else: raise RuntimeError(f"unhandled control-flow construct: {instruction.operation}") continue # Build the node, ignoring any condition. @@ -1130,7 +1130,7 @@ def _build_ast_type(type_: types.Type) -> ast.ClassicalType: return ast.BoolType() if type_.kind is types.Uint: return ast.UintType(type_.width) - raise RuntimeError(f"unhandled expr type '{type_}'") # pragma: no cover + raise RuntimeError(f"unhandled expr type '{type_}'") class _ExprBuilder(expr.ExprVisitor[ast.Expression]):