mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 00:24:47 +04:00
Replace aspy.yaml with sort_keys=False
This commit is contained in:
parent
f0ee93c5a7
commit
a64fa6d478
8 changed files with 36 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import contextlib
|
||||
import errno
|
||||
import functools
|
||||
import os.path
|
||||
import shutil
|
||||
import stat
|
||||
|
|
@ -17,6 +18,8 @@ from typing import Tuple
|
|||
from typing import Type
|
||||
from typing import Union
|
||||
|
||||
import yaml
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
|
||||
if sys.version_info >= (3, 7): # pragma: no cover (PY37+)
|
||||
|
|
@ -28,6 +31,17 @@ else: # pragma: no cover (<PY37)
|
|||
|
||||
EnvironT = Union[Dict[str, str], 'os._Environ']
|
||||
|
||||
Loader = getattr(yaml, 'CSafeLoader', yaml.SafeLoader)
|
||||
yaml_load = functools.partial(yaml.load, Loader=Loader)
|
||||
Dumper = getattr(yaml, 'CSafeDumper', yaml.SafeDumper)
|
||||
|
||||
|
||||
def yaml_dump(o: Any) -> str:
|
||||
# when python/mypy#1484 is solved, this can be `functools.partial`
|
||||
return yaml.dump(
|
||||
o, Dumper=Dumper, default_flow_style=False, indent=4, sort_keys=False,
|
||||
)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def clean_path_on_failure(path: str) -> Generator[None, None, None]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue