mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2025-08-16 19:42:12 +08:00
let pre-commit fix some stuff
This commit is contained in:
@ -7,7 +7,6 @@ from collections import OrderedDict
|
|||||||
import simplejson
|
import simplejson
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _get_pretty_format(contents, indent, sort_keys=True, top_keys=[]):
|
def _get_pretty_format(contents, indent, sort_keys=True, top_keys=[]):
|
||||||
def pairs_first(pairs):
|
def pairs_first(pairs):
|
||||||
before = [pair for pair in pairs if pair[0] in top_keys]
|
before = [pair for pair in pairs if pair[0] in top_keys]
|
||||||
@ -50,10 +49,12 @@ def parse_indent(s):
|
|||||||
'Negative integer supplied to construct JSON indentation delimiter. ',
|
'Negative integer supplied to construct JSON indentation delimiter. ',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_topkeys(s):
|
def parse_topkeys(s):
|
||||||
# type: (str) -> array
|
# type: (str) -> array
|
||||||
return s.split(',')
|
return s.split(',')
|
||||||
|
|
||||||
|
|
||||||
def pretty_format_json(argv=None):
|
def pretty_format_json(argv=None):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -64,14 +64,17 @@ def test_autofix_pretty_format_json(tmpdir):
|
|||||||
ret = pretty_format_json([srcfile.strpath])
|
ret = pretty_format_json([srcfile.strpath])
|
||||||
assert ret == 0
|
assert ret == 0
|
||||||
|
|
||||||
|
|
||||||
def test_orderfile_get_pretty_format():
|
def test_orderfile_get_pretty_format():
|
||||||
ret = pretty_format_json(['--top-keys=alist', get_resource_path('pretty_formatted_json.json')])
|
ret = pretty_format_json(['--top-keys=alist', get_resource_path('pretty_formatted_json.json')])
|
||||||
assert ret == 0
|
assert ret == 0
|
||||||
|
|
||||||
|
|
||||||
def test_not_orderfile_get_pretty_format():
|
def test_not_orderfile_get_pretty_format():
|
||||||
ret = pretty_format_json(['--top-keys=blah', get_resource_path('pretty_formatted_json.json')])
|
ret = pretty_format_json(['--top-keys=blah', get_resource_path('pretty_formatted_json.json')])
|
||||||
assert ret == 1
|
assert ret == 1
|
||||||
|
|
||||||
|
|
||||||
def test_badfile_pretty_format_json():
|
def test_badfile_pretty_format_json():
|
||||||
ret = pretty_format_json([get_resource_path('ok_yaml.yaml')])
|
ret = pretty_format_json([get_resource_path('ok_yaml.yaml')])
|
||||||
assert ret == 1
|
assert ret == 1
|
||||||
|
Reference in New Issue
Block a user