mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 21:04:17 +00:00
feat: add check-yaml feature that allows key duplicates.
This commit is contained in:
parent
119a8f3b2c
commit
85d6a678b4
1 changed files with 11 additions and 0 deletions
|
|
@ -53,8 +53,19 @@ 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(
|
||||||
|
'--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)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
yaml.allow_duplicate_keys = args.allow_duplicate_keys
|
||||||
|
|
||||||
load_fn = LOAD_FNS[Key(multi=args.multi, unsafe=args.unsafe)]
|
load_fn = LOAD_FNS[Key(multi=args.multi, unsafe=args.unsafe)]
|
||||||
|
|
||||||
retval = 0
|
retval = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue