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

First level attribute can be unbound #606

Closed
janjagusch opened this issue Feb 18, 2023 · 1 comment · Fixed by #609
Closed

First level attribute can be unbound #606

janjagusch opened this issue Feb 18, 2023 · 1 comment · Fixed by #609
Assignees

Comments

@janjagusch
Copy link
Collaborator

There is a change that you never enter the while loop, which makes the first_level attribute undefined.

quetz/quetz/config.py

Lines 395 to 408 in efcfdb8

idx = 2
# look for the first level of config_map.
# It must be done in loop as the key itself can contains '_'.
while idx < len(splitted_key):
first_level = self._find_first_level_config(config_key)
if first_level:
break
config_key += f"_{ splitted_key[idx].lower()}"
idx += 1
# no first_level found, the variable is useless.
if not first_level:
continue

This can cause the following error.

UnboundLocalError: cannot access local variable 'first_level' where it is not associated with a value

I feel like this should have been caught by some pre-commit hook (e.g. mypy).

@janjagusch
Copy link
Collaborator Author

Doesn't seem to be so easy to catch this with a pre-commit hook (see python/mypy#2400).

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 a pull request may close this issue.

1 participant