Allow TOML 1.0.0 syntax in check-toml

This commit is contained in:
Taneli Hukkinen 2021-06-02 14:55:41 +03:00
parent f48244a805
commit 4c366d88f7
3 changed files with 11 additions and 7 deletions

View file

@ -2,7 +2,7 @@ import argparse
from typing import Optional
from typing import Sequence
import toml
import tomli
def main(argv: Optional[Sequence[str]] = None) -> int:
@ -12,11 +12,12 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
retval = 0
for filename in args.filenames:
try:
toml.load(filename)
except toml.TomlDecodeError as exc:
print(f'{filename}: {exc}')
retval = 1
with open(filename, encoding='utf-8') as f:
try:
tomli.load(f)
except tomli.TOMLDecodeError as exc:
print(f'{filename}: {exc}')
retval = 1
return retval