| 47 | |
| 48 | |
| 49 | def _validate_config( |
| 50 | retv: int, |
| 51 | config: str, |
| 52 | skip_on_missing_config: bool, |
| 53 | ) -> None: |
| 54 | if not os.path.isfile(config): |
| 55 | if skip_on_missing_config or os.getenv('PRE_COMMIT_ALLOW_NO_CONFIG'): |
| 56 | print(f'`{config}` config file not found. Skipping `pre-commit`.') |
| 57 | raise SystemExit(retv) |
| 58 | else: |
| 59 | print( |
| 60 | f'No {config} file was found\n' |
| 61 | f'- To temporarily silence this, run ' |
| 62 | f'`PRE_COMMIT_ALLOW_NO_CONFIG=1 git ...`\n' |
| 63 | f'- To permanently silence this, install pre-commit with the ' |
| 64 | f'--allow-missing-config option\n' |
| 65 | f'- To uninstall pre-commit run `pre-commit uninstall`', |
| 66 | ) |
| 67 | raise SystemExit(1) |
| 68 | |
| 69 | |
| 70 | def _ns( |