mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Allow TOML 1.0.0 syntax in check-toml
This commit is contained in:
parent
f48244a805
commit
4c366d88f7
3 changed files with 11 additions and 7 deletions
|
|
@ -2,7 +2,7 @@ import argparse
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
import toml
|
import tomli
|
||||||
|
|
||||||
|
|
||||||
def main(argv: Optional[Sequence[str]] = None) -> int:
|
def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||||
|
|
@ -12,11 +12,12 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||||
|
|
||||||
retval = 0
|
retval = 0
|
||||||
for filename in args.filenames:
|
for filename in args.filenames:
|
||||||
try:
|
with open(filename, encoding='utf-8') as f:
|
||||||
toml.load(filename)
|
try:
|
||||||
except toml.TomlDecodeError as exc:
|
tomli.load(f)
|
||||||
print(f'{filename}: {exc}')
|
except tomli.TOMLDecodeError as exc:
|
||||||
retval = 1
|
print(f'{filename}: {exc}')
|
||||||
|
retval = 1
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ classifiers =
|
||||||
packages = find:
|
packages = find:
|
||||||
install_requires =
|
install_requires =
|
||||||
ruamel.yaml>=0.15
|
ruamel.yaml>=0.15
|
||||||
toml
|
tomli
|
||||||
python_requires = >=3.6.1
|
python_requires = >=3.6.1
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ title = "TOML Example"
|
||||||
[owner]
|
[owner]
|
||||||
name = "John"
|
name = "John"
|
||||||
dob = 1979-05-27T07:32:00-08:00 # First class dates
|
dob = 1979-05-27T07:32:00-08:00 # First class dates
|
||||||
|
|
||||||
|
["toml-1.0.0-compat"]
|
||||||
|
heterogeneous-array = [1, "2"]
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
ret = main((str(filename),))
|
ret = main((str(filename),))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue