extended warning if globs are used instead of regex to top level

This commit is contained in:
Paul Fischer 2021-01-01 23:57:24 +01:00
parent 7432acc215
commit b1a9209f9f
No known key found for this signature in database
GPG key ID: 317E3D17B0D3C094
2 changed files with 34 additions and 4 deletions

View file

@ -244,7 +244,7 @@ def test_warn_mutable_rev_conditional():
cfgv.validate(config_obj, CONFIG_REPO_DICT)
def test_validate_optional_sensible_regex(caplog):
def test_validate_optional_sensible_regex_at_hook_level(caplog):
config_obj = {
'id': 'flake8',
'files': 'dir/*.py',
@ -261,6 +261,23 @@ def test_validate_optional_sensible_regex(caplog):
]
def test_validate_optional_sensible_regex_at_top_level(caplog):
config_obj = {
'files': 'dir/*.py',
'repos': [],
}
cfgv.validate(config_obj, CONFIG_SCHEMA)
assert caplog.record_tuples == [
(
'pre_commit',
logging.WARNING,
"The top-level 'files' field is a regex, not a glob -- matching "
"'/*' probably isn't what you want here",
),
]
@pytest.mark.parametrize('fn', (validate_config_main, validate_manifest_main))
def test_mains_not_ok(tmpdir, fn):
not_yaml = tmpdir.join('f.notyaml')