mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-07 20:26:54 +00:00
Merge pull request #351 from pre-commit/ruamel_yaml
switch from pyyaml to ruamel.yaml
This commit is contained in:
commit
de9e7a04b1
2 changed files with 6 additions and 8 deletions
|
|
@ -4,12 +4,9 @@ import argparse
|
||||||
import collections
|
import collections
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import yaml
|
import ruamel.yaml
|
||||||
|
|
||||||
try:
|
yaml = ruamel.yaml.YAML(typ='safe')
|
||||||
from yaml.cyaml import CSafeLoader as Loader
|
|
||||||
except ImportError: # pragma: no cover (no libyaml-dev / pypy)
|
|
||||||
Loader = yaml.SafeLoader
|
|
||||||
|
|
||||||
|
|
||||||
def _exhaust(gen):
|
def _exhaust(gen):
|
||||||
|
|
@ -57,8 +54,9 @@ def check_yaml(argv=None):
|
||||||
retval = 0
|
retval = 0
|
||||||
for filename in args.filenames:
|
for filename in args.filenames:
|
||||||
try:
|
try:
|
||||||
load_fn(open(filename), Loader=Loader)
|
with open(filename) as f:
|
||||||
except yaml.YAMLError as exc:
|
load_fn(f)
|
||||||
|
except ruamel.yaml.YAMLError as exc:
|
||||||
print(exc)
|
print(exc)
|
||||||
retval = 1
|
retval = 1
|
||||||
return retval
|
return retval
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -25,7 +25,7 @@ setup(
|
||||||
packages=find_packages(exclude=('tests*', 'testing*')),
|
packages=find_packages(exclude=('tests*', 'testing*')),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'flake8',
|
'flake8',
|
||||||
'pyyaml',
|
'ruamel.yaml>=0.15',
|
||||||
'six',
|
'six',
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue