From 49c8d589b28a7c4720b6839cb3687450bc329e69 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:45:13 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pre_commit_hooks/check_yaml.py | 13 +++++++------ testing/resources/duplicate_key_yaml.notyaml | 2 +- tests/check_yaml_test.py | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pre_commit_hooks/check_yaml.py b/pre_commit_hooks/check_yaml.py index 8fc7d75..3545c40 100644 --- a/pre_commit_hooks/check_yaml.py +++ b/pre_commit_hooks/check_yaml.py @@ -54,18 +54,19 @@ def main(argv: Sequence[str] | None = None) -> int: ) parser.add_argument('filenames', nargs='*', help='Filenames to check.') parser.add_argument( - '--allow_duplicate_keys', '--allow-duplicate-keys', action='store_true', - help=('In JSON mapping keys should be unique, in YAML they must be unique.' - 'PyYAML never enforced this although the YAML 1.1 specification already required this.' - 'Duplicate keys in mappings are no longer allowed by default.' - 'Use this parameter to allow duplicate keys in yaml files.' + '--allow_duplicate_keys', '--allow-duplicate-keys', action='store_true', + help=( + 'In JSON mapping keys should be unique, in YAML they must be unique.' + 'PyYAML never enforced this although the YAML 1.1 specification already required this.' + 'Duplicate keys in mappings are no longer allowed by default.' + 'Use this parameter to allow duplicate keys in yaml files.' ), ) args = parser.parse_args(argv) yaml.allow_duplicate_keys = args.allow_duplicate_keys - + load_fn = LOAD_FNS[Key(multi=args.multi, unsafe=args.unsafe)] retval = 0 diff --git a/testing/resources/duplicate_key_yaml.notyaml b/testing/resources/duplicate_key_yaml.notyaml index e682077..a572de3 100644 --- a/testing/resources/duplicate_key_yaml.notyaml +++ b/testing/resources/duplicate_key_yaml.notyaml @@ -1,2 +1,2 @@ hello: "world" -hello: "planet" \ No newline at end of file +hello: "planet" diff --git a/tests/check_yaml_test.py b/tests/check_yaml_test.py index ad059fa..08de9cb 100644 --- a/tests/check_yaml_test.py +++ b/tests/check_yaml_test.py @@ -27,6 +27,7 @@ def test_main_allow_multiple_documents(tmpdir): # should pass when we allow multiple documents assert not main(('--allow-multiple-documents', str(f))) + def test_main_allow_duplicate_keys(tmpdir): f = get_resource_path('duplicate_key_yaml.notyaml') # should fail by default