mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-05-06 23:39:13 -05:00
Extend validate_base to take a load_strategy
This commit is contained in:
@@ -24,7 +24,7 @@ def get_validator(
|
||||
exception_type on failure.
|
||||
"""
|
||||
|
||||
def validate(filename=None):
|
||||
def validate(filename=None, load_strategy=yaml.load):
|
||||
filename = filename or os.path.join(git.get_root(), default_filename)
|
||||
|
||||
if not os.path.exists(filename):
|
||||
@@ -33,7 +33,7 @@ def get_validator(
|
||||
file_contents = open(filename, 'r').read()
|
||||
|
||||
try:
|
||||
obj = yaml.load(file_contents)
|
||||
obj = load_strategy(file_contents)
|
||||
except Exception as e:
|
||||
raise exception_type(
|
||||
'File {0} is not a valid yaml file'.format(filename), e,
|
||||
|
||||
Reference in New Issue
Block a user