mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-07 04:26:52 +00:00
Use tomli and tomllib instead of toml
This commit is contained in:
parent
6a5ae704e5
commit
fc88f3fa49
2 changed files with 9 additions and 4 deletions
|
|
@ -1,9 +1,13 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
import toml
|
if sys.version_info >= (3, 11): # pragma: >=3.11 cover
|
||||||
|
import tomllib
|
||||||
|
else: # pragma: <3.11 cover
|
||||||
|
import tomli as tomllib
|
||||||
|
|
||||||
|
|
||||||
def main(argv: Sequence[str] | None = None) -> int:
|
def main(argv: Sequence[str] | None = None) -> int:
|
||||||
|
|
@ -14,8 +18,9 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||||
retval = 0
|
retval = 0
|
||||||
for filename in args.filenames:
|
for filename in args.filenames:
|
||||||
try:
|
try:
|
||||||
toml.load(filename)
|
with open(filename, mode='rb') as fp:
|
||||||
except toml.TomlDecodeError as exc:
|
tomllib.load(fp)
|
||||||
|
except tomllib.TOMLDecodeError as exc:
|
||||||
print(f'{filename}: {exc}')
|
print(f'{filename}: {exc}')
|
||||||
retval = 1
|
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>=1.1.0;python_version<"3.11"
|
||||||
python_requires = >=3.7
|
python_requires = >=3.7
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue