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

Avoid UnboundLocalError when exception is raised #509

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

mcweidner
Copy link
Contributor

@mcweidner mcweidner commented Apr 24, 2023

Adding continue to the except block, otherwise an UnboundLocalError: local variable 'tpl' referenced before assignment is thrown when trying to assign tpl["template_name"] = name after json.loads() raised an exception.

@bosd I think reading the templates should not fail completely because of one invalid template. Maybe we could also be more sensitive about the file types and only try json.loads for .json files instead of every file except .yml files (and for other file types raise a warning that only .yml and .json are supported)? What do you think about this?

in this case 'tpl' is not assigned
@bosd
Copy link
Collaborator

bosd commented Apr 25, 2023

Maybe we could also be more sensitive about the file types and only try json.loads for .json files instead of every file except .yml files

Good Idea, I was unaware of the fact folders could also contain different files.

@bosd bosd merged commit 25ea04c into invoice-x:master Apr 25, 2023
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

Successfully merging this pull request may close these issues.

2 participants