mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-13 06:24:16 +00:00
docs: concise explanation for check-yaml allow duplicate key feature.
This commit is contained in:
parent
aaa58f760c
commit
d788663a74
4 changed files with 11 additions and 10 deletions
|
|
@ -87,9 +87,8 @@ Attempts to load all yaml files to verify syntax.
|
||||||
portability to other yaml implementations.
|
portability to other yaml implementations.
|
||||||
Implies `--allow-multiple-documents`.
|
Implies `--allow-multiple-documents`.
|
||||||
- `--allow_duplicate_keys` - Use this parameter to allow duplicate keys in yaml files.
|
- `--allow_duplicate_keys` - Use this parameter to allow duplicate keys in yaml files.
|
||||||
In JSON mapping keys should be unique, in YAML they must be unique.
|
Duplicate keys in yaml files are not allowed by default.
|
||||||
PyYAML never enforced this although the YAML 1.1 specification already required this.
|
However, e.g. gitlab-ci.yml files may require this.
|
||||||
Duplicate keys in mappings are no longer allowed by default.
|
|
||||||
|
|
||||||
#### `debug-statements`
|
#### `debug-statements`
|
||||||
Check for debugger imports and py37+ `breakpoint()` calls in python source.
|
Check for debugger imports and py37+ `breakpoint()` calls in python source.
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,12 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||||
)
|
)
|
||||||
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
|
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--allow_duplicate_keys', '--allow-duplicate-keys', action='store_true',
|
'--allow_duplicate_keys', '--allow-duplicate-keys',
|
||||||
help=('In JSON mapping keys should be unique, in YAML they must be unique.'
|
action='store_true',
|
||||||
'PyYAML never enforced this although the YAML 1.1 specification already required this.'
|
help=(
|
||||||
'Duplicate keys in mappings are no longer allowed by default.'
|
'Use this parameter to allow duplicate keys in yaml files.'
|
||||||
'Use this parameter to allow duplicate keys in yaml files.'
|
'Duplicate keys in yaml files are not allowed by default.'
|
||||||
|
'However, e.g. gitlab-ci.yml files may require this.'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ def test_main_allow_multiple_documents(tmpdir):
|
||||||
# should pass when we allow multiple documents
|
# should pass when we allow multiple documents
|
||||||
assert not main(('--allow-multiple-documents', str(f)))
|
assert not main(('--allow-multiple-documents', str(f)))
|
||||||
|
|
||||||
|
|
||||||
def test_main_allow_duplicate_keys(tmpdir):
|
def test_main_allow_duplicate_keys(tmpdir):
|
||||||
f = get_resource_path('duplicate_key_yaml.notyaml')
|
f = get_resource_path('duplicate_key_yaml.notyaml')
|
||||||
# should fail by default
|
# should fail by default
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue