(argv: list[str] | None = None)
| 294 | |
| 295 | |
| 296 | def main(argv: list[str] | None = None) -> int: |
| 297 | parser = argparse.ArgumentParser( |
| 298 | description="Check Python files for proper KeyboardInterrupt handling.", |
| 299 | ) |
| 300 | parser.add_argument( |
| 301 | "paths", |
| 302 | nargs="+", |
| 303 | help="Files or directories to check", |
| 304 | ) |
| 305 | parser.add_argument( |
| 306 | "--exclude", |
| 307 | nargs="*", |
| 308 | default=[], |
| 309 | help="Substrings to exclude from file paths", |
| 310 | ) |
| 311 | args = parser.parse_args(argv) |
| 312 | |
| 313 | files = collect_python_files(args.paths, args.exclude) |
| 314 | candidates = find_candidates(files) |
| 315 | |
| 316 | total_violations = 0 |
| 317 | for path, source in candidates: |
| 318 | violations = check_file(str(path), source) |
| 319 | for v in violations: |
| 320 | print(f"{path}:{v.line}:{v.col}: {v}") |
| 321 | total_violations += 1 |
| 322 | |
| 323 | return 1 if total_violations > 0 else 0 |
| 324 | |
| 325 | |
| 326 | if __name__ == "__main__": |
no test coverage detected