Skip to content

First level attribute can be unbound #606

Closed
@janjagusch

Description

@janjagusch

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).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions