(entrypoint_abs: str | None)
| 40 | |
| 41 | |
| 42 | def has_main_guard(entrypoint_abs: str | None) -> bool: |
| 43 | if not entrypoint_abs: |
| 44 | return False |
| 45 | |
| 46 | try: |
| 47 | with open(entrypoint_abs, encoding="utf-8") as file: |
| 48 | source = file.read() |
| 49 | except Exception: |
| 50 | return False |
| 51 | |
| 52 | try: |
| 53 | tree = ast.parse(source, filename=entrypoint_abs) |
| 54 | except Exception: |
| 55 | return False |
| 56 | |
| 57 | for node in ast.walk(tree): |
| 58 | if isinstance(node, ast.If) and _is_main_guard_test(node.test): |
| 59 | return True |
| 60 | return False |
| 61 | |
| 62 | |
| 63 | def run_entrypoint_as_main(entrypoint_abs: str) -> None: |
nothing calls this directly
no test coverage detected