mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-29 10:16:52 +00:00
Fix exc. raising logic to match validation issues
This commit is contained in:
parent
a5628863e8
commit
abaf0d12de
1 changed files with 8 additions and 7 deletions
|
|
@ -28,19 +28,20 @@ def parse_indent(s):
|
|||
# type: (str) -> str
|
||||
try:
|
||||
int_indentation_spec = int(s)
|
||||
except ValueError:
|
||||
if not s.strip():
|
||||
return s
|
||||
else:
|
||||
raise ValueError(
|
||||
'Non-whitespace JSON indentation delimiter supplied. ',
|
||||
)
|
||||
else:
|
||||
if int_indentation_spec >= 0:
|
||||
return int_indentation_spec * ' '
|
||||
else:
|
||||
raise ValueError(
|
||||
'Negative integer supplied to construct JSON indentation delimiter. ',
|
||||
)
|
||||
except ValueError:
|
||||
if s.strip() == '':
|
||||
return s
|
||||
else:
|
||||
raise ValueError(
|
||||
'Non-whitespace JSON indentation delimiter supplied. ',
|
||||
)
|
||||
|
||||
|
||||
def pretty_format_json(argv=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue