mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Replace jsonschema with better error messages
This commit is contained in:
parent
71bbdb5b4c
commit
cb8dd335f4
30 changed files with 1064 additions and 842 deletions
|
|
@ -10,10 +10,10 @@ from aspy.yaml import ordered_dump
|
|||
from aspy.yaml import ordered_load
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA
|
||||
from pre_commit.clientlib.validate_config import validate_config_extra
|
||||
from pre_commit.clientlib.validate_manifest import load_manifest
|
||||
from pre_commit.jsonschema_extensions import apply_defaults
|
||||
from pre_commit.clientlib import CONFIG_SCHEMA
|
||||
from pre_commit.clientlib import load_manifest
|
||||
from pre_commit.schema import apply_defaults
|
||||
from pre_commit.schema import validate
|
||||
from pre_commit.util import cmd_output
|
||||
from pre_commit.util import copy_tree_to_path
|
||||
from pre_commit.util import cwd
|
||||
|
|
@ -94,9 +94,9 @@ def make_config_from_repo(
|
|||
))
|
||||
|
||||
if check:
|
||||
wrapped_config = apply_defaults([config], CONFIG_JSON_SCHEMA)
|
||||
validate_config_extra(wrapped_config)
|
||||
return wrapped_config[0]
|
||||
wrapped = validate([config], CONFIG_SCHEMA)
|
||||
config, = apply_defaults(wrapped, CONFIG_SCHEMA)
|
||||
return config
|
||||
else:
|
||||
return config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
- foo
|
||||
- bar
|
||||
|
|
@ -1 +0,0 @@
|
|||
foo: "
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
foo: bar
|
||||
bar: baz
|
||||
|
|
@ -2,7 +2,6 @@ from __future__ import unicode_literals
|
|||
|
||||
import os.path
|
||||
|
||||
import jsonschema
|
||||
import pytest
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
|
|
@ -24,14 +23,6 @@ def get_head_sha(dir):
|
|||
return cmd_output('git', 'rev-parse', 'HEAD')[1].strip()
|
||||
|
||||
|
||||
def is_valid_according_to_schema(obj, schema):
|
||||
try:
|
||||
jsonschema.validate(obj, schema)
|
||||
return True
|
||||
except jsonschema.exceptions.ValidationError:
|
||||
return False
|
||||
|
||||
|
||||
def cmd_output_mocked_pre_commit_home(*args, **kwargs):
|
||||
# keyword-only argument
|
||||
tempdir_factory = kwargs.pop('tempdir_factory')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue