Skip to content

Commit

Permalink
exclude lines from coverage report (#12564) (#12570)
Browse files Browse the repository at this point in the history
* exclude lines from coverage

* comments with explanation

* to pyproject from tox

(cherry picked from commit 2d6a5a2)

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
  • Loading branch information
mergify[bot] and 1ucian0 authored Jun 13, 2024
1 parent af59a8e commit 03aeee8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
4 changes: 2 additions & 2 deletions qiskit/qasm3/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]):
Expand Down

0 comments on commit 03aeee8

Please sign in to comment.