Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deirokay.validate() without a value for the save_to parameter resulting in NameError #50

Open
lfenzo opened this issue Mar 9, 2023 · 0 comments

Comments

@lfenzo
Copy link

lfenzo commented Mar 9, 2023

Experienced while trying call deirokay.validate() without providing a value for save_to. As in the source code, the save_to_fs variable is accessed regardless of the value in save_to (which defaults to None in the function definition) resulting in a NameError: free variable 'save_to_fs' referenced before assignment in enclosing scope. However, the "Getting started" example in the documentation somehow works without passing save_to.

if save_to:
save_to_fs = fs_factory(save_to)
if isinstance(save_to_fs, LocalFileSystem) and not save_to_fs.isdir():
raise ValueError('The `save_to` parameter must be an existing'
' directory or an S3 path.')
if isinstance(against, str):
save_format = save_format or splitext(against)[1].lstrip('.')
validation_document = fs_factory(against).read_dict()
else:
save_format = save_format or 'yaml'
validation_document = deepcopy(against)
assert save_format.lower() in ('json', 'yaml', 'yml'), (
f'Not a valid format {save_format}'
)
# Render templates
template = dict(
series=lambda x, y: get_series(x, y, read_from=save_to_fs),
**(template or {})
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant