mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-05-02 13:29:13 -05:00
Add warning to additional keys in config
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
import cfgv
|
||||
import pytest
|
||||
|
||||
@@ -116,6 +118,27 @@ def test_validate_config_old_list_format_ok(tmpdir):
|
||||
assert not validate_config_main((f.strpath,))
|
||||
|
||||
|
||||
def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog):
|
||||
f = tmpdir.join('cfg.yaml')
|
||||
f.write(
|
||||
'- repo: https://gitlab.com/pycqa/flake8\n'
|
||||
' rev: 3.7.7\n'
|
||||
' hooks:\n'
|
||||
' - id: flake8\n'
|
||||
' args: [--some-args]\n',
|
||||
)
|
||||
ret_val = validate_config_main((f.strpath,))
|
||||
assert not ret_val
|
||||
assert caplog.record_tuples == [
|
||||
(
|
||||
'pre_commit',
|
||||
logging.WARNING,
|
||||
'Your pre-commit-config contain these extra keys: args. '
|
||||
'while the only valid keys are: hooks, repo, rev.',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fn', (validate_config_main, validate_manifest_main))
|
||||
def test_mains_not_ok(tmpdir, fn):
|
||||
not_yaml = tmpdir.join('f.notyaml')
|
||||
|
||||
Reference in New Issue
Block a user