Use match case just because we can
@@ -389,16 +389,17 @@ class BranchCoverageInstrumentation(InstrumentationAdapter):
)
operation = block[self._COMPARE_OP_POS]
- if operation.name == "COMPARE_OP":
+ match operation.name:
+ case "COMPARE_OP":
compare = operation.arg
- elif operation.name == "IS_OP":
+ case "IS_OP":
# Beginning with 3.9, there are separate OPs for various comparisons.
# Map them back to the old operations, so we can use the enum from the
# bytecode library.
compare = Compare.IS_NOT if operation.arg else Compare.IS
- elif operation.name == "CONTAINS_OP":
+ case "CONTAINS_OP":
compare = Compare.NOT_IN if operation.arg else Compare.IN
- else:
+ case _:
raise RuntimeError(f"Unknown comparison OP {operation}")
# Insert instructions right before the comparison.
