mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2025-08-14 17:31:28 +08:00
Fix exc. raising logic to match validation issues
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user