def _extract_all_branches(python_source: str): parser = PythonParser(text=python_source) # This is a hack to force-disable Python optimization, otherwise Python will optimize away statements like # "if False: ..." and that would cause unexpected diffs in the coverage branches. Even when passing optimize=0 to # compile(). parser._byte_parser = _FakeByteParser( num_lines=len(python_source.splitlines()) + 1) parser.parse_source() return parser.arcs()