From 155e4619294e7636933938da44761d5cccbbaf97 Mon Sep 17 00:00:00 2001 From: Matthew Small Date: Mon, 4 Dec 2023 14:49:50 -0500 Subject: [PATCH] Update validate_config.py Add prints to alert user when no configs were passed to be validated and inform user which configs were validated. --- pre_commit/commands/validate_config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pre_commit/commands/validate_config.py b/pre_commit/commands/validate_config.py index b3de635b..911348bd 100644 --- a/pre_commit/commands/validate_config.py +++ b/pre_commit/commands/validate_config.py @@ -8,11 +8,16 @@ from pre_commit import clientlib def validate_config(filenames: Sequence[str]) -> int: ret = 0 + if not filenames: + raise FileNotFoundError("No files found. Did you supply a config to validate? (E.g. pre-commit validate-config path/to/.pre-commit-config.yaml)") + for filename in filenames: try: clientlib.load_config(filename) except clientlib.InvalidConfigError as e: print(e) ret = 1 - + if ret == 0: + formatted_filenames = "\n".join([filename for filename in filenames]) + print(f"The following configs were validated:\n{formatted_filenames}") return ret