Add a check and test to the real top level and improve the warning message

This commit is contained in:
Yoav Caspi
2019-05-11 22:57:52 +03:00
parent fd9d9d276b
commit 217d31ec1c
2 changed files with 32 additions and 9 deletions

View File

@@ -149,12 +149,10 @@ def _entry(modname):
def warn_on_unknown_keys_at_top_level(extra, orig_keys):
logger.warning(
'Your pre-commit-config contain these extra keys: {}. '
'while the only valid keys are: {}.'.format(
', '.join(extra),
', '.join(sorted(orig_keys)),
'Unexpected config key(s): {}'.format(
', '.join(sorted(extra)),
),
),
)
_meta = (
@@ -236,7 +234,7 @@ CONFIG_REPO_DICT = cfgv.Map(
MigrateShaToRev(),
cfgv.WarnAdditionalKeys(
{'repo', 'rev', 'hooks'},
('repo', 'rev', 'hooks'),
warn_on_unknown_keys_at_top_level,
),
)
@@ -264,6 +262,10 @@ CONFIG_SCHEMA = cfgv.Map(
cfgv.check_and(cfgv.check_string, check_min_version),
'0',
),
cfgv.WarnAdditionalKeys(
('repos',),
warn_on_unknown_keys_at_top_level,
),
)